Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-03-30 01:57:40
Exec Total Coverage
Lines: 1771 4241 41.8%
Functions: 128 345 37.1%
Branches: 951 2706 35.1%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 #include "zc_sys.h"
17
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35 #include "dialog/cheatkeys.h"
36
37 #ifdef ALLEGRO_DOS
38 #include <unistd.h>
39 #endif
40
41 #include "metadata/metadata.h"
42 #include "zelda.h"
43 #include "tiles.h"
44 #include "base/colors.h"
45 #include "pal.h"
46 #include "base/zsys.h"
47 #include "qst.h"
48 #include "zc_sys.h"
49 #include "play_midi.h"
50 #include "debug.h"
51 #include "jwin_a5.h"
52 #include "base/jwinfsel.h"
53 #include "base/gui.h"
54 #include "midi.h"
55 #include "subscr.h"
56 #include "maps.h"
57 #include "sprite.h"
58 #include "guys.h"
59 #include "hero.h"
60 #include "title.h"
61 #include "particles.h"
62 #include "zconsole.h"
63 #include "ffscript.h"
64 #include "dialog/info.h"
65 #include "dialog/alert.h"
66 #include <fmt/format.h>
67
68 #ifdef __EMSCRIPTEN__
69 #include "base/emscripten_utils.h"
70 #endif
71
72 extern FFScript FFCore;
73 extern bool Playing;
74 int32_t sfx_voice[WAV_COUNT];
75 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
76 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
77
78 extern byte monochrome_console;
79
80 extern HeroClass Hero;
81 extern FFScript FFCore;
82 extern ZModule zcm;
83 extern zcmodule moduledata;
84 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
85 extern particle_list particles;
86 extern int32_t loadlast;
87 extern word passive_subscreen_doscript;
88 extern bool passive_subscreen_waitdraw;
89 extern char *sfx_string[WAV_COUNT];
90 byte use_dwm_flush;
91 byte use_save_indicator;
92 byte midi_patch_fix;
93 bool midi_paused=false;
94 int32_t paused_midi_pos = 0;
95 byte midi_suspended = 0;
96 byte callback_switchin = 0;
97 byte zc_192b163_warp_compatibility;
98 char modulepath[2048];
99 bool epilepsyFlashReduction;
100 signed char pause_in_background_menu_init = 0;
101 byte pause_in_background = 0;
102 bool is_sys_pal = false;
103 static bool load_control_called_this_frame;
104 extern PALETTE* hw_palette;
105 extern bool update_hw_pal;
106 extern const char* dmaplist(int32_t index, int32_t* list_size);
107 int32_t getnumber(const char *prompt,int32_t initialval);
108
109 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
110 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
111 //extern byte refresh_select_screen;
112 //extern movingblock mblock2; //mblock[4]?
113 //extern int32_t db;
114
115 static const char *ZC_str = "Zelda Classic";
116 extern char save_file_name[1024];
117 #ifdef ALLEGRO_DOS
118 const char *qst_dir_name = "dos_qst_dir";
119 #elif defined(ALLEGRO_WINDOWS)
120 const char *qst_dir_name = "win_qst_dir";
121 static const char *qst_module_name = "current_module";
122 #elif defined(ALLEGRO_LINUX)
123 const char *qst_dir_name = "linux_qst_dir";
124 static const char *qst_module_name = "current_module";
125 #elif defined(__APPLE__)
126 const char *qst_dir_name = "osx_qst_dir";
127 static const char *qst_module_name = "current_module";
128 #endif
129 #ifdef ALLEGRO_LINUX
130 static const char *samplepath = "samplesoundset/patches.dat";
131 #endif
132 char qst_files_path[2048];
133
134 #ifdef _MSC_VER
135 #define getcwd _getcwd
136 #endif
137
138 bool rF11();
139 bool rI();
140 bool rQ();
141 bool zc_key_pressed();
142
143 #ifdef _WIN32
144
145 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
146 extern "C"
147 {
148 typedef HRESULT(WINAPI *t_DwmFlush)();
149 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
150 }
151
152 void do_DwmFlush()
153 {
154 static HMODULE shell = LoadLibrary("dwmapi.dll");
155
156 if(!shell)
157 return;
158
159 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
160 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
161
162 BOOL enabled;
163 isEnabled(&enabled);
164
165 if(isEnabled)
166 flush();
167 }
168
169 #endif // _WIN32
170
171 82019 bool flash_reduction_enabled(bool check_qr)
172 {
173
4/4
✓ Branch 0 taken 79798 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 79342 times.
✓ Branch 3 taken 81563 times.
82019 return (check_qr && get_bit(quest_rules, qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
174 }
175
176 // Dialogue largening
177 void large_dialog(DIALOG *d)
178 {
179 large_dialog(d, 1.5);
180 }
181
182 void large_dialog(DIALOG *d, float RESIZE_AMT)
183 {
184 if(!d[0].d1)
185 {
186 d[0].d1 = 1;
187 int32_t oldwidth = d[0].w;
188 int32_t oldheight = d[0].h;
189 int32_t oldx = d[0].x;
190 int32_t oldy = d[0].y;
191 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
192 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
193 d[0].w = int32_t(d[0].w*RESIZE_AMT);
194 d[0].h = int32_t(d[0].h*RESIZE_AMT);
195
196 for(int32_t i=1; d[i].proc !=NULL; i++)
197 {
198 // Place elements horizontally
199 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
200 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
201
202 if(d[i].proc != d_stringloader)
203 {
204 if(d[i].proc==d_bitmap_proc)
205 {
206 d[i].w *= 2;
207 }
208 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
209 }
210
211 // Place elements vertically
212 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
213 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
214
215 // Vertically resize elements
216 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
217 {
218 d[i].h = int32_t((double)d[i].h*1.5);
219 }
220 else if(d[i].proc == jwin_droplist_proc)
221 {
222 d[i].y += int32_t((double)d[i].h*0.25);
223 d[i].h = int32_t((double)d[i].h*1.25);
224 }
225 else if(d[i].proc==d_bitmap_proc)
226 {
227 d[i].h *= 2;
228 }
229 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
230
231 // Fix frames
232 if(d[i].proc == jwin_frame_proc)
233 {
234 d[i].x++;
235 d[i].y++;
236 d[i].w-=4;
237 d[i].h-=4;
238 }
239 }
240 }
241
242 for(int32_t i=1; d[i].proc!=NULL; i++)
243 {
244 if(d[i].proc==jwin_slider_proc)
245 continue;
246
247 // Bigger font
248 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
249
250 if(!d[i].dp2 && bigfontproc)
251 {
252 d[i].dp2 = get_zc_font(font_lfont_l);
253 }
254 else if(!bigfontproc)
255 {
256 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
257 }
258
259 // Make checkboxes work
260 if(d[i].proc == jwin_check_proc)
261 d[i].proc = jwin_checkfont_proc;
262 else if(d[i].proc == jwin_radio_proc)
263 d[i].proc = jwin_radiofont_proc;
264 }
265
266 jwin_center_dialog(d);
267 }
268
269
270 /**********************************/
271 /******** System functions ********/
272 /**********************************/
273
274 static char cfg_sect[] = "zeldadx"; //We need to rename this.
275 static char ctrl_sect[] = "Controls";
276 static char sfx_sect[] = "Volume";
277
278 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
279 {
280 return D_O_K;
281 }
282
283 bool is_reserved_key(int c)
284 {
285 switch(c)
286 {
287 case KEY_ESC:
288 return true;
289 }
290 return false;
291 }
292 bool is_reserved_keycombo(int c, int modflag)
293 {
294 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
295 return true;
296 return false;
297 }
298 bool checkcheat(Cheat cheat)
299 {
300 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
301 return true; //Main key pressed
302 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
303 return true; //Alt key pressed
304 return false;
305 }
306 29 void load_default_cheatkeys()
307 {
308 29 memset(cheatkeys, 0, sizeof(cheatkeys));
309 29 cheatkeys[Cheat::Life][0] = KEY_H;
310 29 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
311 29 cheatkeys[Cheat::Magic][0] = KEY_M;
312 29 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
313 29 cheatkeys[Cheat::Rupies][0] = KEY_R;
314 29 cheatkeys[Cheat::Bombs][0] = KEY_B;
315 29 cheatkeys[Cheat::Arrows][0] = KEY_A;
316 29 cheatkeys[Cheat::Clock][0] = KEY_I;
317 29 cheatkeys[Cheat::Walls][0] = KEY_F11;
318 29 cheatkeys[Cheat::Fast][0] = KEY_Q;
319 29 cheatkeys[Cheat::Light][0] = KEY_L;
320 29 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
321 29 cheatkeys[Cheat::Kill][0] = KEY_K;
322 29 cheatkeys[Cheat::GoTo][0] = KEY_G;
323 29 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
324 29 cheatkeys[Cheat::ShowL0][0] = KEY_0;
325 29 cheatkeys[Cheat::ShowL1][0] = KEY_1;
326 29 cheatkeys[Cheat::ShowL2][0] = KEY_2;
327 29 cheatkeys[Cheat::ShowL3][0] = KEY_3;
328 29 cheatkeys[Cheat::ShowL4][0] = KEY_4;
329 29 cheatkeys[Cheat::ShowL5][0] = KEY_5;
330 29 cheatkeys[Cheat::ShowL6][0] = KEY_6;
331 29 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
332 29 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
333 29 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
334 29 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
335 29 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
336 29 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
337 29 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
338 29 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
339 29 }
340 29 void load_game_configs()
341 {
342 29 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
343 29 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
344 29 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
345 29 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
346 29 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
347 29 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
348 29 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
349 29 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
350 29 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
351 29 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
352 29 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
353 29 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
354 29 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
355 29 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
356 29 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
357
358 //cheat modifier keya
359 29 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
360 29 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
361 29 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
362 29 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
363
364 //cheat keys
365 29 load_default_cheatkeys();
366 char buf[256];
367
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 29 times.
1044 for(size_t q = 1; q < Cheat::Last; ++q)
368 {
369
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 if(!bindable_cheat((Cheat)q)) continue;
370 1015 std::string cheatname = cheat_to_string((Cheat)q);
371
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 util::lowerstr(cheatname);
372 1015 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
373
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
374 1015 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
375
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
376 1015 }
377
378
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
379 joystick_index = 0;
380
381 29 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
382 29 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
383 29 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
384 29 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
385 29 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
386 29 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
387 29 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
388 29 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
389 29 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
390 29 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
391
392 29 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
393 29 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
394 29 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
395 29 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
396
397 29 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
398 29 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
399 29 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
400 29 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
401 29 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
402 29 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
403 29 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
404 29 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
405 29 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
406 29 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
407 29 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
408
409 29 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
410 29 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
411 29 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
412 29 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
413
414 29 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
415
416 29 digi_volume = zc_get_config(sfx_sect,"digi",248);
417 29 midi_volume = zc_get_config(sfx_sect,"midi",255);
418 29 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
419 29 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
420 29 pan_style = zc_get_config(sfx_sect,"pan",1);
421 // 1 <= zcmusic_bufsz <= 128
422 29 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
423 29 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
424 29 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
425 29 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
426 29 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
427 29 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
428 29 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
429 #ifdef __EMSCRIPTEN__
430 if (em_is_mobile()) NameEntryMode = 2;
431 #endif
432 29 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
433 29 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
434 29 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
435 29 title_version = zc_get_config(cfg_sect,"title",2);
436 29 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
437 29 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
438
439 //default - scale x2, 640 x 480
440 29 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
441 29 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
442 29 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
443 29 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
444 29 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
445 29 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
446
447 29 loadlast = zc_get_config(cfg_sect,"load_last",0);
448
449 29 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
450
451 29 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
452
453 29 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
454 29 info_opacity = zc_get_config("zc","debug_info_opacity",255);
455 #ifdef _WIN32
456 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
457 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
458 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
459 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
460
461 // This one's for Aero
462 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
463
464 // And this one fixes patches unloading on some MIDI setups
465 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
466 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
467 #else //UNIX
468 29 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
469 29 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
470 29 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
471 #endif
472 29 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
473 29 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
474
475 29 char const* default_path = "";
476 29 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,default_path));
477
478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(strlen(qstdir)==0)
479 {
480 29 getcwd(qstdir,2048);
481 29 fix_filename_case(qstdir);
482 29 fix_filename_slashes(qstdir);
483 29 put_backslash(qstdir);
484 29 }
485 else
486 {
487 chop_path(qstdir);
488 }
489
490 29 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
491 29 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
492 29 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
493 29 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
494 29 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
495 29 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
496 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
497 29 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
498 29 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
499 29 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
500 29 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
501 29 }
502
503 void save_control_configs(bool kb)
504 {
505 if(kb)
506 {
507 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
508 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
509 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
510 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
511
512 if (!replay_is_replaying())
513 {
514 zc_set_config(ctrl_sect,"key_a",Akey);
515 zc_set_config(ctrl_sect,"key_b",Bkey);
516 zc_set_config(ctrl_sect,"key_s",Skey);
517 zc_set_config(ctrl_sect,"key_l",Lkey);
518 zc_set_config(ctrl_sect,"key_r",Rkey);
519 zc_set_config(ctrl_sect,"key_p",Pkey);
520 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
521 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
522 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
523 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
524 zc_set_config(ctrl_sect,"key_up", DUkey);
525 zc_set_config(ctrl_sect,"key_down", DDkey);
526 zc_set_config(ctrl_sect,"key_left", DLkey);
527 zc_set_config(ctrl_sect,"key_right",DRkey);
528 }
529 }
530 else
531 {
532 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
533 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
534 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
535 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
536 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
537 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
538 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
539 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
540 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
541 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
542 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
543 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
544 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
545 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
546
547 zc_set_config(ctrl_sect,"btn_a",Abtn);
548 zc_set_config(ctrl_sect,"btn_b",Bbtn);
549 zc_set_config(ctrl_sect,"btn_s",Sbtn);
550 zc_set_config(ctrl_sect,"btn_m",Mbtn);
551 zc_set_config(ctrl_sect,"btn_l",Lbtn);
552 zc_set_config(ctrl_sect,"btn_r",Rbtn);
553 zc_set_config(ctrl_sect,"btn_p",Pbtn);
554 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
555 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
556 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
557 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
558
559 zc_set_config(ctrl_sect,"btn_up",DUbtn);
560 zc_set_config(ctrl_sect,"btn_down",DDbtn);
561 zc_set_config(ctrl_sect,"btn_left",DLbtn);
562 zc_set_config(ctrl_sect,"btn_right",DRbtn);
563 }
564 }
565
566 void save_cheatkeys()
567 {
568 char buf[256];
569 for(size_t q = 1; q < Cheat::Last; ++q)
570 {
571 if(!bindable_cheat((Cheat)q)) continue;
572 std::string cheatname = cheat_to_string((Cheat)q);
573 util::lowerstr(cheatname);
574 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
575 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
576 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
577 if(cheatkeys[q][1])
578 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
579 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
580 }
581 }
582
583 void save_game_configs()
584 {
585 packfile_password("");
586
587 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
588
589 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
590 {
591 int o_window_x, o_window_y;
592 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
593 zc_set_config(cfg_sect,"window_x",o_window_x);
594 zc_set_config(cfg_sect,"window_y",o_window_y);
595 }
596
597 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
598 {
599 double monitor_scale = zc_get_monitor_scale();
600 window_width = al_get_display_width(all_get_display()) / monitor_scale;
601 window_height = al_get_display_height(all_get_display()) / monitor_scale;
602 zc_set_config(cfg_sect,"window_width",window_width);
603 zc_set_config(cfg_sect,"window_height",window_height);
604 }
605
606 zc_set_config(cfg_sect,"load_last",loadlast);
607 chop_path(qstdir);
608 zc_set_config(cfg_sect,qst_dir_name,qstdir);
609 zc_set_config("SAVEFILE","save_filename",save_file_name);
610 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
611
612 flush_config_file();
613 #ifdef __EMSCRIPTEN__
614 em_sync_fs();
615 #endif
616 }
617
618 //----------------------------------------------------------------
619
620 // Timers
621
622 32115 void fps_callback()
623 {
624 32115 lastfps=framecnt;
625 32115 dword tempsecs = fps_secs;
626 32115 ++tempsecs;
627 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
628 32115 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
629 32115 ++fps_secs;
630 32115 framecnt=0;
631 32115 }
632
633 END_OF_FUNCTION(fps_callback)
634
635 29 int32_t Z_init_timers()
636 {
637 static bool didit = false;
638 const static char *err_str = "Couldn't allocate timer";
639 29 err_str = err_str; //Unused variable warning
640
641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(didit)
642 return 1;
643
644 29 didit = true;
645
646 LOCK_VARIABLE(lastfps);
647 LOCK_VARIABLE(framecnt);
648 LOCK_FUNCTION(fps_callback);
649
650
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
651 return 0;
652
653 29 return 1;
654 29 }
655
656 void Z_remove_timers()
657 {
658 remove_int(fps_callback);
659 }
660
661 //----------------------------------------------------------------
662
663 void go()
664 {
665 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
666 }
667
668 void comeback()
669 {
670 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
671 }
672
673 void dump_pal(BITMAP *dest)
674 {
675 for(int32_t i=0; i<256; i++)
676 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
677 }
678
679 //----------------------------------------------------------------
680
681 //Handles converting the mouse sprite from the .dat file
682 29 void load_mouse()
683 {
684 29 system_pal();
685 29 MouseSprite::set(-1);
686 29 int32_t sz = vbound(int32_t(16*(zc_get_config("zeldadx","cursor_scale_large",1.5))),16,80);
687
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t j = 0; j < 4; ++j)
688 {
689 116 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
690 116 BITMAP* subbmp = create_bitmap_ex(8,16,16);
691
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(zcmouse[j])
692 destroy_bitmap(zcmouse[j]);
693 116 zcmouse[j] = create_bitmap_ex(8,sz,sz);
694 116 clear_bitmap(zcmouse[j]);
695 116 clear_bitmap(tmpbmp);
696 116 clear_bitmap(subbmp);
697 116 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
698
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 116 times.
1972 for(int32_t x = 0; x < 16; ++x)
699 {
700
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 1856 times.
31552 for(int32_t y = 0; y < 16; ++y)
701 {
702 29696 int32_t color = getpixel(tmpbmp, x, y);
703
5/5
✓ Branch 0 taken 27318 times.
✓ Branch 1 taken 551 times.
✓ Branch 2 taken 638 times.
✓ Branch 3 taken 667 times.
✓ Branch 4 taken 522 times.
29696 switch(color)
704 {
705 case dvc(1):
706 551 color = jwin_pal[jcCURSORMISC];
707 551 break;
708 case dvc(2):
709 638 color = jwin_pal[jcCURSOROUTLINE];
710 638 break;
711 case dvc(3):
712 667 color = jwin_pal[jcCURSORLIGHT];
713 667 break;
714 case dvc(5):
715 522 color = jwin_pal[jcCURSORDARK];
716 522 break;
717 }
718 29696 putpixel(subbmp, x, y, color);
719 29696 }
720 1856 }
721
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(sz!=16)
722 116 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
723 else
724 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
725 116 destroy_bitmap(tmpbmp);
726 116 destroy_bitmap(subbmp);
727 116 }
728 29 zc_set_palette(*hw_palette);
729
730 29 MouseSprite::assign(0, zcmouse[0]);
731 29 MouseSprite::set(0);
732
733 29 game_pal();
734 29 }
735
736 // sets the video mode and initializes the palette and mouse sprite
737 29 bool game_vid_mode(int32_t mode,int32_t wait)
738 {
739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
740 {
741 return false;
742 }
743
744 29 scrx = (resx-320)>>1;
745 29 scry = (resy-240)>>1;
746
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
747 116 zcmouse[q] = NULL;
748 29 load_mouse();
749
750
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 29 times.
493 for(int32_t i=240; i<256; i++)
751 464 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
752
753 29 zc_set_palette(RAMpal);
754 29 clear_to_color(screen,BLACK);
755
756 29 rest(wait);
757 29 return true;
758 29 }
759
760 5 void null_quest()
761 {
762 char qstdat_string[2048];
763 5 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
764 5 strcat(qstdat_string,"#NESQST_NEW_QST");
765
766 #ifdef __EMSCRIPTEN__
767 // The quest template data file is not included because it's really big and isn't really needed
768 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
769 // which is much smaller.
770 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
771 #endif
772
773 5 byte skip_flags[4] = { 0 };
774
775 5 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
776 5 }
777
778 5 void init_NES_mode()
779 {
780 /*
781 // qst.dat may not load correctly without this...
782 QHeader.templatepath[0]='\0';
783
784 if(!init_colordata(true, &QHeader, &QMisc))
785 {
786 return;
787 }
788
789 loadfullpal();
790 init_tiles(false, &QHeader);
791 */
792 5 null_quest();
793 5 }
794
795 //----------------------------------------------------------------
796
797 qword trianglelines[16]=
798 {
799 0x0000000000000000ULL,
800 0xFD00000000000000ULL,
801 0xFDFD000000000000ULL,
802 0xFDFDFD0000000000ULL,
803 0xFDFDFDFD00000000ULL,
804 0xFDFDFDFDFD000000ULL,
805 0xFDFDFDFDFDFD0000ULL,
806 0xFDFDFDFDFDFDFD00ULL,
807 0xFDFDFDFDFDFDFDFDULL,
808 0x00FDFDFDFDFDFDFDULL,
809 0x0000FDFDFDFDFDFDULL,
810 0x000000FDFDFDFDFDULL,
811 0x00000000FDFDFDFDULL,
812 0x0000000000FDFDFDULL,
813 0x000000000000FDFDULL,
814 0x00000000000000FDULL,
815 };
816
817 word screen_triangles[28][32];
818 /*
819 qword triangles[4][16]= //[direction][value]
820 {
821 {
822 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
823 },
824 {
825 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
826 },
827 {
828 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
829 },
830 {
831 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
832 }
833 };
834 */
835
836
837 /*
838 byte triangles[4][16][8]= //[direction][value][line]
839 {
840 {
841 {
842 0, 0, 0, 0, 0, 0, 0, 0
843 },
844 {
845 1, 0, 0, 0, 0, 0, 0, 0
846 },
847 {
848 2, 1, 0, 0, 0, 0, 0, 0
849 },
850 {
851 3, 2, 1, 0, 0, 0, 0, 0
852 },
853 {
854 4, 3, 2, 1, 0, 0, 0, 0
855 },
856 {
857 5, 4, 3, 2, 1, 0, 0, 0
858 },
859 {
860 6, 5, 4, 3, 2, 1, 0, 0
861 },
862 {
863 7, 6, 5, 4, 3, 2, 1, 0
864 },
865 {
866 8, 7, 6, 5, 4, 3, 2, 1
867 },
868 {
869 8, 8, 7, 6, 5, 4, 3, 2
870 },
871 {
872 8, 8, 8, 7, 6, 5, 4, 3
873 },
874 {
875 8, 8, 8, 8, 7, 6, 5, 4
876 },
877 {
878 8, 8, 8, 8, 8, 7, 6, 5
879 },
880 {
881 8, 8, 8, 8, 8, 8, 7, 6
882 },
883 {
884 8, 8, 8, 8, 8, 8, 8, 7
885 },
886 {
887 8, 8, 8, 8, 8, 8, 8, 8
888 }
889 },
890 {
891 {
892 0, 0, 0, 0, 0, 0, 0, 0
893 },
894 {
895 15, 0, 0, 0, 0, 0, 0, 0
896 },
897 {
898 14, 15, 0, 0, 0, 0, 0, 0
899 },
900 {
901 13, 14, 15, 0, 0, 0, 0, 0
902 },
903 {
904 12, 13, 14, 15, 0, 0, 0, 0
905 },
906 {
907 11, 12, 13, 14, 15, 0, 0, 0
908 },
909 {
910 10, 11, 12, 13, 14, 15, 0, 0
911 },
912 {
913 9, 10, 11, 12, 13, 14, 15, 0
914 },
915 {
916 8, 9, 10, 11, 12, 13, 14, 15
917 },
918 {
919 8, 8, 9, 10, 11, 12, 13, 14
920 },
921 {
922 8, 8, 8, 9, 10, 11, 12, 13
923 },
924 {
925 8, 8, 8, 8, 9, 10, 11, 12
926 },
927 {
928 8, 8, 8, 8, 8, 9, 10, 11
929 },
930 {
931 8, 8, 8, 8, 8, 8, 9, 10
932 },
933 {
934 8, 8, 8, 8, 8, 8, 8, 9
935 },
936 {
937 8, 8, 8, 8, 8, 8, 8, 8
938 }
939 },
940 {
941 {
942 0, 0, 0, 0, 0, 0, 0, 0
943 },
944 {
945 0, 0, 0, 0, 0, 0, 0, 1
946 },
947 {
948 0, 0, 0, 0, 0, 0, 1, 2
949 },
950 {
951 0, 0, 0, 0, 0, 1, 2, 3
952 },
953 {
954 0, 0, 0, 0, 1, 2, 3, 4
955 },
956 {
957 0, 0, 0, 1, 2, 3, 4, 5
958 },
959 {
960 0, 0, 1, 2, 3, 4, 5, 6
961 },
962 {
963 0, 1, 2, 3, 4, 5, 6, 7
964 },
965 {
966 1, 2, 3, 4, 5, 6, 7, 8
967 },
968 {
969 2, 3, 4, 5, 6, 7, 8, 8
970 },
971 {
972 3, 4, 5, 6, 7, 8, 8, 8
973 },
974 {
975 4, 5, 6, 7, 8, 8, 8, 8
976 },
977 {
978 5, 6, 7, 8, 8, 8, 8, 8
979 },
980 {
981 6, 7, 8, 8, 8, 8, 8, 8
982 },
983 {
984 7, 8, 8, 8, 8, 8, 8, 8
985 },
986 {
987 8, 8, 8, 8, 8, 8, 8, 8
988 }
989 },
990 {
991 {
992 0, 0, 0, 0, 0, 0, 0, 0
993 },
994 {
995 0, 0, 0, 0, 0, 0, 0, 15
996 },
997 {
998 0, 0, 0, 0, 0, 0, 15, 14
999 },
1000 {
1001 0, 0, 0, 0, 0, 15, 14, 13
1002 },
1003 {
1004 0, 0, 0, 0, 15, 14, 13, 12
1005 },
1006 {
1007 0, 0, 0, 15, 14, 13, 12, 11
1008 },
1009 {
1010 0, 0, 15, 14, 13, 12, 11, 10
1011 },
1012 {
1013 0, 15, 14, 13, 12, 11, 10, 9
1014 },
1015 {
1016 15, 14, 13, 12, 11, 10, 9, 8
1017 },
1018 {
1019 14, 13, 12, 11, 10, 9, 8, 8
1020 },
1021 {
1022 13, 12, 11, 10, 9, 8, 8, 8
1023 },
1024 {
1025 12, 11, 10, 9, 8, 8, 8, 8
1026 },
1027 {
1028 11, 10, 9, 8, 8, 8, 8, 8
1029 },
1030 {
1031 10, 9, 8, 8, 8, 8, 8, 8
1032 },
1033 {
1034 9, 8, 8, 8, 8, 8, 8, 8
1035 },
1036 {
1037 8, 8, 8, 8, 8, 8, 8, 8
1038 }
1039 }
1040 };
1041 */
1042
1043
1044
1045 /*
1046 for (int32_t blockrow=0; blockrow<30; ++i)
1047 {
1048 for (int32_t linerow=0; linerow<8; ++i)
1049 {
1050 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1051 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1052 {
1053 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1054 ++triangleline;
1055 }
1056 }
1057 }
1058 */
1059
1060 // the ULL suffixes are to prevent this warning:
1061 // warning: integer constant is too large for "int32_t" type
1062
1063 qword triangles[4][16][8]= //[direction][value][line]
1064 {
1065 {
1066 {
1067 0x0000000000000000ULL,
1068 0x0000000000000000ULL,
1069 0x0000000000000000ULL,
1070 0x0000000000000000ULL,
1071 0x0000000000000000ULL,
1072 0x0000000000000000ULL,
1073 0x0000000000000000ULL,
1074 0x0000000000000000ULL
1075 },
1076 {
1077 0xFD00000000000000ULL,
1078 0x0000000000000000ULL,
1079 0x0000000000000000ULL,
1080 0x0000000000000000ULL,
1081 0x0000000000000000ULL,
1082 0x0000000000000000ULL,
1083 0x0000000000000000ULL,
1084 0x0000000000000000ULL
1085 },
1086 {
1087 0xFDFD000000000000ULL,
1088 0xFD00000000000000ULL,
1089 0x0000000000000000ULL,
1090 0x0000000000000000ULL,
1091 0x0000000000000000ULL,
1092 0x0000000000000000ULL,
1093 0x0000000000000000ULL,
1094 0x0000000000000000ULL
1095 },
1096 {
1097 0xFDFDFD0000000000ULL,
1098 0xFDFD000000000000ULL,
1099 0xFD00000000000000ULL,
1100 0x0000000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL
1105 },
1106 {
1107 0xFDFDFDFD00000000ULL,
1108 0xFDFDFD0000000000ULL,
1109 0xFDFD000000000000ULL,
1110 0xFD00000000000000ULL,
1111 0x0000000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL
1115 },
1116 {
1117 0xFDFDFDFDFD000000ULL,
1118 0xFDFDFDFD00000000ULL,
1119 0xFDFDFD0000000000ULL,
1120 0xFDFD000000000000ULL,
1121 0xFD00000000000000ULL,
1122 0x0000000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL
1125 },
1126 {
1127 0xFDFDFDFDFDFD0000ULL,
1128 0xFDFDFDFDFD000000ULL,
1129 0xFDFDFDFD00000000ULL,
1130 0xFDFDFD0000000000ULL,
1131 0xFDFD000000000000ULL,
1132 0xFD00000000000000ULL,
1133 0x0000000000000000ULL,
1134 0x0000000000000000ULL
1135 },
1136 {
1137 0xFDFDFDFDFDFDFD00ULL,
1138 0xFDFDFDFDFDFD0000ULL,
1139 0xFDFDFDFDFD000000ULL,
1140 0xFDFDFDFD00000000ULL,
1141 0xFDFDFD0000000000ULL,
1142 0xFDFD000000000000ULL,
1143 0xFD00000000000000ULL,
1144 0x0000000000000000ULL
1145 },
1146 {
1147 0xFDFDFDFDFDFDFDFDULL,
1148 0xFDFDFDFDFDFDFD00ULL,
1149 0xFDFDFDFDFDFD0000ULL,
1150 0xFDFDFDFDFD000000ULL,
1151 0xFDFDFDFD00000000ULL,
1152 0xFDFDFD0000000000ULL,
1153 0xFDFD000000000000ULL,
1154 0xFD00000000000000ULL
1155 },
1156 {
1157 0xFDFDFDFDFDFDFDFDULL,
1158 0xFDFDFDFDFDFDFDFDULL,
1159 0xFDFDFDFDFDFDFD00ULL,
1160 0xFDFDFDFDFDFD0000ULL,
1161 0xFDFDFDFDFD000000ULL,
1162 0xFDFDFDFD00000000ULL,
1163 0xFDFDFD0000000000ULL,
1164 0xFDFD000000000000ULL
1165 },
1166 {
1167 0xFDFDFDFDFDFDFDFDULL,
1168 0xFDFDFDFDFDFDFDFDULL,
1169 0xFDFDFDFDFDFDFDFDULL,
1170 0xFDFDFDFDFDFDFD00ULL,
1171 0xFDFDFDFDFDFD0000ULL,
1172 0xFDFDFDFDFD000000ULL,
1173 0xFDFDFDFD00000000ULL,
1174 0xFDFDFD0000000000ULL
1175 },
1176 {
1177 0xFDFDFDFDFDFDFDFDULL,
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFDFDULL,
1180 0xFDFDFDFDFDFDFDFDULL,
1181 0xFDFDFDFDFDFDFD00ULL,
1182 0xFDFDFDFDFDFD0000ULL,
1183 0xFDFDFDFDFD000000ULL,
1184 0xFDFDFDFD00000000ULL
1185 },
1186 {
1187 0xFDFDFDFDFDFDFDFDULL,
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFDFDULL,
1192 0xFDFDFDFDFDFDFD00ULL,
1193 0xFDFDFDFDFDFD0000ULL,
1194 0xFDFDFDFDFD000000ULL
1195 },
1196 {
1197 0xFDFDFDFDFDFDFDFDULL,
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFDFDULL,
1203 0xFDFDFDFDFDFDFD00ULL,
1204 0xFDFDFDFDFDFD0000ULL
1205 },
1206 {
1207 0xFDFDFDFDFDFDFDFDULL,
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFDFDULL,
1214 0xFDFDFDFDFDFDFD00ULL
1215 },
1216 {
1217 0xFDFDFDFDFDFDFDFDULL,
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0xFDFDFDFDFDFDFDFDULL
1225 }
1226 },
1227 {
1228 {
1229 0x0000000000000000ULL,
1230 0x0000000000000000ULL,
1231 0x0000000000000000ULL,
1232 0x0000000000000000ULL,
1233 0x0000000000000000ULL,
1234 0x0000000000000000ULL,
1235 0x0000000000000000ULL,
1236 0x0000000000000000ULL
1237 },
1238 {
1239 0x00000000000000FDULL,
1240 0x0000000000000000ULL,
1241 0x0000000000000000ULL,
1242 0x0000000000000000ULL,
1243 0x0000000000000000ULL,
1244 0x0000000000000000ULL,
1245 0x0000000000000000ULL,
1246 0x0000000000000000ULL
1247 },
1248 {
1249 0x000000000000FDFDULL,
1250 0x00000000000000FDULL,
1251 0x0000000000000000ULL,
1252 0x0000000000000000ULL,
1253 0x0000000000000000ULL,
1254 0x0000000000000000ULL,
1255 0x0000000000000000ULL,
1256 0x0000000000000000ULL
1257 },
1258 {
1259 0x0000000000FDFDFDULL,
1260 0x000000000000FDFDULL,
1261 0x00000000000000FDULL,
1262 0x0000000000000000ULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL
1267 },
1268 {
1269 0x00000000FDFDFDFDULL,
1270 0x0000000000FDFDFDULL,
1271 0x000000000000FDFDULL,
1272 0x00000000000000FDULL,
1273 0x0000000000000000ULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL
1277 },
1278 {
1279 0x000000FDFDFDFDFDULL,
1280 0x00000000FDFDFDFDULL,
1281 0x0000000000FDFDFDULL,
1282 0x000000000000FDFDULL,
1283 0x00000000000000FDULL,
1284 0x0000000000000000ULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL
1287 },
1288 {
1289 0x0000FDFDFDFDFDFDULL,
1290 0x000000FDFDFDFDFDULL,
1291 0x00000000FDFDFDFDULL,
1292 0x0000000000FDFDFDULL,
1293 0x000000000000FDFDULL,
1294 0x00000000000000FDULL,
1295 0x0000000000000000ULL,
1296 0x0000000000000000ULL
1297 },
1298 {
1299 0x00FDFDFDFDFDFDFDULL,
1300 0x0000FDFDFDFDFDFDULL,
1301 0x000000FDFDFDFDFDULL,
1302 0x00000000FDFDFDFDULL,
1303 0x0000000000FDFDFDULL,
1304 0x000000000000FDFDULL,
1305 0x00000000000000FDULL,
1306 0x0000000000000000ULL
1307 },
1308 {
1309 0xFDFDFDFDFDFDFDFDULL,
1310 0x00FDFDFDFDFDFDFDULL,
1311 0x0000FDFDFDFDFDFDULL,
1312 0x000000FDFDFDFDFDULL,
1313 0x00000000FDFDFDFDULL,
1314 0x0000000000FDFDFDULL,
1315 0x000000000000FDFDULL,
1316 0x00000000000000FDULL
1317 },
1318 {
1319 0xFDFDFDFDFDFDFDFDULL,
1320 0xFDFDFDFDFDFDFDFDULL,
1321 0x00FDFDFDFDFDFDFDULL,
1322 0x0000FDFDFDFDFDFDULL,
1323 0x000000FDFDFDFDFDULL,
1324 0x00000000FDFDFDFDULL,
1325 0x0000000000FDFDFDULL,
1326 0x000000000000FDFDULL
1327 },
1328 {
1329 0xFDFDFDFDFDFDFDFDULL,
1330 0xFDFDFDFDFDFDFDFDULL,
1331 0xFDFDFDFDFDFDFDFDULL,
1332 0x00FDFDFDFDFDFDFDULL,
1333 0x0000FDFDFDFDFDFDULL,
1334 0x000000FDFDFDFDFDULL,
1335 0x00000000FDFDFDFDULL,
1336 0x0000000000FDFDFDULL
1337 },
1338 {
1339 0xFDFDFDFDFDFDFDFDULL,
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0xFDFDFDFDFDFDFDFDULL,
1342 0xFDFDFDFDFDFDFDFDULL,
1343 0x00FDFDFDFDFDFDFDULL,
1344 0x0000FDFDFDFDFDFDULL,
1345 0x000000FDFDFDFDFDULL,
1346 0x00000000FDFDFDFDULL
1347 },
1348 {
1349 0xFDFDFDFDFDFDFDFDULL,
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0xFDFDFDFDFDFDFDFDULL,
1354 0x00FDFDFDFDFDFDFDULL,
1355 0x0000FDFDFDFDFDFDULL,
1356 0x000000FDFDFDFDFDULL
1357 },
1358 {
1359 0xFDFDFDFDFDFDFDFDULL,
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0xFDFDFDFDFDFDFDFDULL,
1365 0x00FDFDFDFDFDFDFDULL,
1366 0x0000FDFDFDFDFDFDULL
1367 },
1368 {
1369 0xFDFDFDFDFDFDFDFDULL,
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0xFDFDFDFDFDFDFDFDULL,
1376 0x00FDFDFDFDFDFDFDULL
1377 },
1378 {
1379 0xFDFDFDFDFDFDFDFDULL,
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL,
1386 0xFDFDFDFDFDFDFDFDULL
1387 }
1388 },
1389 {
1390 {
1391 0x0000000000000000ULL,
1392 0x0000000000000000ULL,
1393 0x0000000000000000ULL,
1394 0x0000000000000000ULL,
1395 0x0000000000000000ULL,
1396 0x0000000000000000ULL,
1397 0x0000000000000000ULL,
1398 0x0000000000000000ULL
1399 },
1400 {
1401 0x0000000000000000ULL,
1402 0x0000000000000000ULL,
1403 0x0000000000000000ULL,
1404 0x0000000000000000ULL,
1405 0x0000000000000000ULL,
1406 0x0000000000000000ULL,
1407 0x0000000000000000ULL,
1408 0xFD00000000000000ULL
1409 },
1410 {
1411 0x0000000000000000ULL,
1412 0x0000000000000000ULL,
1413 0x0000000000000000ULL,
1414 0x0000000000000000ULL,
1415 0x0000000000000000ULL,
1416 0x0000000000000000ULL,
1417 0xFD00000000000000ULL,
1418 0xFDFD000000000000ULL
1419 },
1420 {
1421 0x0000000000000000ULL,
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0xFD00000000000000ULL,
1427 0xFDFD000000000000ULL,
1428 0xFDFDFD0000000000ULL
1429 },
1430 {
1431 0x0000000000000000ULL,
1432 0x0000000000000000ULL,
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0xFD00000000000000ULL,
1436 0xFDFD000000000000ULL,
1437 0xFDFDFD0000000000ULL,
1438 0xFDFDFDFD00000000ULL
1439 },
1440 {
1441 0x0000000000000000ULL,
1442 0x0000000000000000ULL,
1443 0x0000000000000000ULL,
1444 0xFD00000000000000ULL,
1445 0xFDFD000000000000ULL,
1446 0xFDFDFD0000000000ULL,
1447 0xFDFDFDFD00000000ULL,
1448 0xFDFDFDFDFD000000ULL
1449 },
1450 {
1451 0x0000000000000000ULL,
1452 0x0000000000000000ULL,
1453 0xFD00000000000000ULL,
1454 0xFDFD000000000000ULL,
1455 0xFDFDFD0000000000ULL,
1456 0xFDFDFDFD00000000ULL,
1457 0xFDFDFDFDFD000000ULL,
1458 0xFDFDFDFDFDFD0000ULL
1459 },
1460 {
1461 0x0000000000000000ULL,
1462 0xFD00000000000000ULL,
1463 0xFDFD000000000000ULL,
1464 0xFDFDFD0000000000ULL,
1465 0xFDFDFDFD00000000ULL,
1466 0xFDFDFDFDFD000000ULL,
1467 0xFDFDFDFDFDFD0000ULL,
1468 0xFDFDFDFDFDFDFD00ULL
1469 },
1470 {
1471 0xFD00000000000000ULL,
1472 0xFDFD000000000000ULL,
1473 0xFDFDFD0000000000ULL,
1474 0xFDFDFDFD00000000ULL,
1475 0xFDFDFDFDFD000000ULL,
1476 0xFDFDFDFDFDFD0000ULL,
1477 0xFDFDFDFDFDFDFD00ULL,
1478 0xFDFDFDFDFDFDFDFDULL
1479 },
1480 {
1481 0xFDFD000000000000ULL,
1482 0xFDFDFD0000000000ULL,
1483 0xFDFDFDFD00000000ULL,
1484 0xFDFDFDFDFD000000ULL,
1485 0xFDFDFDFDFDFD0000ULL,
1486 0xFDFDFDFDFDFDFD00ULL,
1487 0xFDFDFDFDFDFDFDFDULL,
1488 0xFDFDFDFDFDFDFDFDULL
1489 },
1490 {
1491 0xFDFDFD0000000000ULL,
1492 0xFDFDFDFD00000000ULL,
1493 0xFDFDFDFDFD000000ULL,
1494 0xFDFDFDFDFDFD0000ULL,
1495 0xFDFDFDFDFDFDFD00ULL,
1496 0xFDFDFDFDFDFDFDFDULL,
1497 0xFDFDFDFDFDFDFDFDULL,
1498 0xFDFDFDFDFDFDFDFDULL
1499 },
1500 {
1501 0xFDFDFDFD00000000ULL,
1502 0xFDFDFDFDFD000000ULL,
1503 0xFDFDFDFDFDFD0000ULL,
1504 0xFDFDFDFDFDFDFD00ULL,
1505 0xFDFDFDFDFDFDFDFDULL,
1506 0xFDFDFDFDFDFDFDFDULL,
1507 0xFDFDFDFDFDFDFDFDULL,
1508 0xFDFDFDFDFDFDFDFDULL
1509 },
1510 {
1511 0xFDFDFDFDFD000000ULL,
1512 0xFDFDFDFDFDFD0000ULL,
1513 0xFDFDFDFDFDFDFD00ULL,
1514 0xFDFDFDFDFDFDFDFDULL,
1515 0xFDFDFDFDFDFDFDFDULL,
1516 0xFDFDFDFDFDFDFDFDULL,
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL
1519 },
1520 {
1521 0xFDFDFDFDFDFD0000ULL,
1522 0xFDFDFDFDFDFDFD00ULL,
1523 0xFDFDFDFDFDFDFDFDULL,
1524 0xFDFDFDFDFDFDFDFDULL,
1525 0xFDFDFDFDFDFDFDFDULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL
1529 },
1530 {
1531 0xFDFDFDFDFDFDFD00ULL,
1532 0xFDFDFDFDFDFDFDFDULL,
1533 0xFDFDFDFDFDFDFDFDULL,
1534 0xFDFDFDFDFDFDFDFDULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL
1539 },
1540 {
1541 0xFDFDFDFDFDFDFDFDULL,
1542 0xFDFDFDFDFDFDFDFDULL,
1543 0xFDFDFDFDFDFDFDFDULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL
1549 }
1550 },
1551 {
1552 {
1553 0x0000000000000000ULL,
1554 0x0000000000000000ULL,
1555 0x0000000000000000ULL,
1556 0x0000000000000000ULL,
1557 0x0000000000000000ULL,
1558 0x0000000000000000ULL,
1559 0x0000000000000000ULL,
1560 0x0000000000000000ULL
1561 },
1562 {
1563 0x0000000000000000ULL,
1564 0x0000000000000000ULL,
1565 0x0000000000000000ULL,
1566 0x0000000000000000ULL,
1567 0x0000000000000000ULL,
1568 0x0000000000000000ULL,
1569 0x0000000000000000ULL,
1570 0x00000000000000FDULL
1571 },
1572 {
1573 0x0000000000000000ULL,
1574 0x0000000000000000ULL,
1575 0x0000000000000000ULL,
1576 0x0000000000000000ULL,
1577 0x0000000000000000ULL,
1578 0x0000000000000000ULL,
1579 0x00000000000000FDULL,
1580 0x000000000000FDFDULL
1581 },
1582 {
1583 0x0000000000000000ULL,
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x00000000000000FDULL,
1589 0x000000000000FDFDULL,
1590 0x0000000000FDFDFDULL
1591 },
1592 {
1593 0x0000000000000000ULL,
1594 0x0000000000000000ULL,
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x00000000000000FDULL,
1598 0x000000000000FDFDULL,
1599 0x0000000000FDFDFDULL,
1600 0x00000000FDFDFDFDULL
1601 },
1602 {
1603 0x0000000000000000ULL,
1604 0x0000000000000000ULL,
1605 0x0000000000000000ULL,
1606 0x00000000000000FDULL,
1607 0x000000000000FDFDULL,
1608 0x0000000000FDFDFDULL,
1609 0x00000000FDFDFDFDULL,
1610 0x000000FDFDFDFDFDULL
1611 },
1612 {
1613 0x0000000000000000ULL,
1614 0x0000000000000000ULL,
1615 0x00000000000000FDULL,
1616 0x000000000000FDFDULL,
1617 0x0000000000FDFDFDULL,
1618 0x00000000FDFDFDFDULL,
1619 0x000000FDFDFDFDFDULL,
1620 0x0000FDFDFDFDFDFDULL
1621 },
1622 {
1623 0x0000000000000000ULL,
1624 0x00000000000000FDULL,
1625 0x000000000000FDFDULL,
1626 0x0000000000FDFDFDULL,
1627 0x00000000FDFDFDFDULL,
1628 0x000000FDFDFDFDFDULL,
1629 0x0000FDFDFDFDFDFDULL,
1630 0x00FDFDFDFDFDFDFDULL
1631 },
1632 {
1633 0x00000000000000FDULL,
1634 0x000000000000FDFDULL,
1635 0x0000000000FDFDFDULL,
1636 0x00000000FDFDFDFDULL,
1637 0x000000FDFDFDFDFDULL,
1638 0x0000FDFDFDFDFDFDULL,
1639 0x00FDFDFDFDFDFDFDULL,
1640 0xFDFDFDFDFDFDFDFDULL
1641 },
1642 {
1643 0x000000000000FDFDULL,
1644 0x0000000000FDFDFDULL,
1645 0x00000000FDFDFDFDULL,
1646 0x000000FDFDFDFDFDULL,
1647 0x0000FDFDFDFDFDFDULL,
1648 0x00FDFDFDFDFDFDFDULL,
1649 0xFDFDFDFDFDFDFDFDULL,
1650 0xFDFDFDFDFDFDFDFDULL
1651 },
1652 {
1653 0x0000000000FDFDFDULL,
1654 0x00000000FDFDFDFDULL,
1655 0x000000FDFDFDFDFDULL,
1656 0x0000FDFDFDFDFDFDULL,
1657 0x00FDFDFDFDFDFDFDULL,
1658 0xFDFDFDFDFDFDFDFDULL,
1659 0xFDFDFDFDFDFDFDFDULL,
1660 0xFDFDFDFDFDFDFDFDULL
1661 },
1662 {
1663 0x00000000FDFDFDFDULL,
1664 0x000000FDFDFDFDFDULL,
1665 0x0000FDFDFDFDFDFDULL,
1666 0x00FDFDFDFDFDFDFDULL,
1667 0xFDFDFDFDFDFDFDFDULL,
1668 0xFDFDFDFDFDFDFDFDULL,
1669 0xFDFDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL
1671 },
1672 {
1673 0x000000FDFDFDFDFDULL,
1674 0x0000FDFDFDFDFDFDULL,
1675 0x00FDFDFDFDFDFDFDULL,
1676 0xFDFDFDFDFDFDFDFDULL,
1677 0xFDFDFDFDFDFDFDFDULL,
1678 0xFDFDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL
1681 },
1682 {
1683 0x0000FDFDFDFDFDFDULL,
1684 0x00FDFDFDFDFDFDFDULL,
1685 0xFDFDFDFDFDFDFDFDULL,
1686 0xFDFDFDFDFDFDFDFDULL,
1687 0xFDFDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL
1691 },
1692 {
1693 0x00FDFDFDFDFDFDFDULL,
1694 0xFDFDFDFDFDFDFDFDULL,
1695 0xFDFDFDFDFDFDFDFDULL,
1696 0xFDFDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL
1701 },
1702 {
1703 0xFDFDFDFDFDFDFDFDULL,
1704 0xFDFDFDFDFDFDFDFDULL,
1705 0xFDFDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL
1711 }
1712 }
1713 };
1714
1715 int32_t black_opening_count=0;
1716 int32_t black_opening_x,black_opening_y;
1717 int32_t black_opening_shape;
1718
1719 791 int32_t choose_opening_shape()
1720 {
1721 // First, count how many bits are set
1722 791 int32_t numBits=0;
1723 int32_t bitCounter;
1724
1725
2/2
✓ Branch 0 taken 3955 times.
✓ Branch 1 taken 791 times.
4746 for(int32_t i=0; i<bosMAX; i++)
1726 {
1727
2/2
✓ Branch 0 taken 2948 times.
✓ Branch 1 taken 1007 times.
3955 if(COOLSCROLL&(1<<i))
1728 1007 numBits++;
1729 3955 }
1730
1731 // Shouldn't happen...
1732
1/2
✓ Branch 0 taken 791 times.
✗ Branch 1 not taken.
791 if(numBits==0)
1733 return bosCIRCLE;
1734
1735 // Pick a bit
1736 791 bitCounter=zc_rand()%numBits+1;
1737
1738
2/2
✓ Branch 0 taken 1003 times.
✓ Branch 1 taken 26 times.
1029 for(int32_t i=0; i<bosMAX; i++)
1739 {
1740 // If this bit is set, decrement the bit counter
1741
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 921 times.
1003 if(COOLSCROLL&(1<<i))
1742 921 bitCounter--;
1743
1744 // When the counter hits 0, return a value based on
1745 // which bit it stopped on.
1746 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1747
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 238 times.
1003 if(bitCounter==0)
1748 765 return i;
1749 238 }
1750
1751 // Shouldn't be necessary, but the compiler might complain, at least
1752 26 return bosCIRCLE;
1753 791 }
1754
1755 216 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1756 {
1757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1758
1759 216 int32_t w=256, h=224;
1760 216 int32_t blockrows=28, blockcolumns=32;
1761 216 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1762
1763
2/2
✓ Branch 0 taken 6048 times.
✓ Branch 1 taken 216 times.
6264 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1764 {
1765
2/2
✓ Branch 0 taken 193536 times.
✓ Branch 1 taken 6048 times.
199584 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1766 {
1767
2/2
✓ Branch 0 taken 103944 times.
✓ Branch 1 taken 89592 times.
193536 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1768 193536 }
1769 6048 }
1770
1771 216 black_opening_count = 66;
1772 216 black_opening_x = x;
1773 216 black_opening_y = y;
1774 216 lensclk = 0;
1775 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1776
1777
1778
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(black_opening_shape == bosFADEBLACK)
1779 {
1780 refreshTints();
1781 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1782 }
1783
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(wait)
1784 {
1785 FFCore.warpScriptCheck();
1786 for(int32_t i=0; i<66; i++)
1787 {
1788 draw_screen(tmpscr);
1789 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1790 advanceframe(true);
1791
1792 if(Quit)
1793 {
1794 break;
1795 }
1796 }
1797 }
1798 216 }
1799
1800 575 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1801 {
1802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
575 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1803
1804 575 int32_t w=256, h=224;
1805 575 int32_t blockrows=28, blockcolumns=32;
1806 575 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1807
1808
2/2
✓ Branch 0 taken 16100 times.
✓ Branch 1 taken 575 times.
16675 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1809 {
1810
2/2
✓ Branch 0 taken 515200 times.
✓ Branch 1 taken 16100 times.
531300 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1811 {
1812
2/2
✓ Branch 0 taken 241603 times.
✓ Branch 1 taken 273597 times.
515200 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1813 515200 }
1814 16100 }
1815
1816 575 black_opening_count = -66;
1817 575 black_opening_x = x;
1818 575 black_opening_y = y;
1819 575 lensclk = 0;
1820
1/2
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
575 if(black_opening_shape == bosFADEBLACK)
1821 {
1822 refreshTints();
1823 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1824 }
1825
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 465 times.
575 if(wait)
1826 {
1827 465 FFCore.warpScriptCheck();
1828
2/2
✓ Branch 0 taken 465 times.
✓ Branch 1 taken 30690 times.
31155 for(int32_t i=0; i<66; i++)
1829 {
1830 30690 draw_screen(tmpscr);
1831 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1832 30690 advanceframe(true);
1833
1834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30690 times.
30690 if(Quit)
1835 {
1836 break;
1837 }
1838 30690 }
1839 465 }
1840 575 }
1841
1842 52206 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1843 {
1844 52206 clear_to_color(tmp_scr,BLACK);
1845 52206 int32_t w=256, h=224;
1846
1847
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 1650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 49038 times.
52206 switch(black_opening_shape)
1848 {
1849 case bosOVAL:
1850 {
1851 858 double new_w=(w/2)+abs(w/2-x);
1852 858 double new_h=(h/2)+abs(h/2-y);
1853 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1854 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1855 858 break;
1856 }
1857
1858 case bosTRIANGLE:
1859 {
1860 660 double new_w=(w/2)+abs(w/2-x);
1861 660 double new_h=(h/2)+abs(h/2-y);
1862 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1863 660 double P2= (PI/2);
1864 660 double P23=(2*PI/3);
1865 660 double P43=(4*PI/3);
1866 660 double Pa= (-4*PI*a/(3*max_a));
1867 660 double angle=P2+Pa;
1868 660 double a0=angle;
1869 660 double a2=angle+P23;
1870 660 double a4=angle+P43;
1871 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1872 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1873 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1874 0);
1875 660 break;
1876 }
1877
1878 case bosSMAS:
1879 {
1880
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 990 times.
1650 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1881
1882
2/2
✓ Branch 0 taken 46200 times.
✓ Branch 1 taken 1650 times.
47850 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1883 {
1884
2/2
✓ Branch 0 taken 369600 times.
✓ Branch 1 taken 46200 times.
415800 for(int32_t linerow=0; linerow<8; ++linerow)
1885 {
1886 369600 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1887
1888
2/2
✓ Branch 0 taken 11827200 times.
✓ Branch 1 taken 369600 times.
12196800 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1889 {
1890 35481600 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1891
6/6
✓ Branch 0 taken 8249728 times.
✓ Branch 1 taken 3577472 times.
✓ Branch 2 taken 7829672 times.
✓ Branch 3 taken 3997528 times.
✓ Branch 4 taken 4252200 times.
✓ Branch 5 taken 3577472 times.
11827200 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1892 11827200 [linerow];
1893 11827200 ++triangleline;
1894
1895
2/2
✓ Branch 0 taken 10348800 times.
✓ Branch 1 taken 1478400 times.
11827200 if(linerow==0)
1896 {
1897 1478400 }
1898 11827200 }
1899 369600 }
1900 46200 }
1901
1902 1650 break;
1903 }
1904
1905 case bosFADEBLACK:
1906 {
1907 if(black_opening_count<0)
1908 {
1909 black_fade(zc_min(-black_opening_count,63));
1910 }
1911 else if(black_opening_count>0)
1912 {
1913 black_fade(63-zc_max(black_opening_count-3,0));
1914 }
1915 else black_fade(0);
1916 return; //no blitting from tmp_scr!
1917 }
1918
1919 49038 case bosCIRCLE:
1920 default:
1921 {
1922 49038 double new_w=(w/2)+abs(w/2-x);
1923 49038 double new_h=(h/2)+abs(h/2-y);
1924 49038 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1925 //circlefill(tmp_scr,x,y,a<<3,0);
1926 49038 circlefill(tmp_scr,x,y,r,0);
1927 49038 break;
1928 }
1929 }
1930
1931 52206 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1932 52206 }
1933
1934
1935 void black_fade(int32_t fadeamnt)
1936 {
1937 for(int32_t i=0; i < 0xEF; i++)
1938 {
1939 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1940 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1941 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1942 }
1943
1944 refreshpal = true;
1945 }
1946
1947 //----------------------------------------------------------------
1948
1949 15952490 bool item_disabled(int32_t item) //is this item disabled?
1950 {
1951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15952490 times.
15952490 return (item>=0 && game->items_off[item] != 0);
1952 }
1953
1954 5426600 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1955 {
1956
2/2
✓ Branch 0 taken 57842 times.
✓ Branch 1 taken 5368758 times.
5426600 if(current_item(item_type, true) >=item)
1957 {
1958 57842 return true;
1959 }
1960
1961 5368758 return false;
1962 5426600 }
1963
1964 22449319 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1965 {
1966
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4086346 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2439977 times.
✓ Branch 6 taken 12012783 times.
✓ Branch 7 taken 3882589 times.
✓ Branch 8 taken 27624 times.
22449319 switch(item_type)
1967 {
1968 case itype_bomb:
1969 case itype_sbomb:
1970 {
1971 int32_t itemid = getItemID(itemsbuf, item_type, it);
1972
1973 if(itemid == -1)
1974 return false;
1975
1976 return (game->get_item(itemid));
1977 }
1978
1979 case itype_clock:
1980 {
1981 4086346 int32_t itemid = getItemID(itemsbuf, item_type, it);
1982
1983
2/4
✓ Branch 0 taken 4086346 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4086346 times.
✗ Branch 3 not taken.
4086346 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1984 return (game->get_item(itemid));
1985 4086346 return Hero.getClock()?1:0;
1986 }
1987
1988 case itype_key:
1989 return (game->get_keys()>0);
1990
1991 case itype_magiccontainer:
1992 return (game->get_maxmagic()>=game->get_mp_per_block());
1993
1994 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1995 {
1996
1/3
✓ Branch 0 taken 2439977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2439977 switch(it)
1997 {
1998 case -2:
1999 {
2000 for(int32_t i=0; i<MAXLEVELS; i++)
2001 {
2002 if(game->lvlitems[i]&liTRIFORCE)
2003 {
2004 return true;
2005 }
2006 }
2007
2008 return false;
2009 }
2010
2011 case -1:
2012 return (game->lvlitems[dlevel]&liTRIFORCE);
2013
2014 default:
2015
2/4
✓ Branch 0 taken 2439977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2439977 times.
2439977 if(it>=0&&it<MAXLEVELS)
2016 {
2017 2439977 return (game->lvlitems[it]&liTRIFORCE);
2018 }
2019
2020 break;
2021 }
2022
2023 return 0;
2024 }
2025
2026 case itype_map: //it: -2=any, -1=current level, other=that level
2027 {
2028
1/3
✓ Branch 0 taken 12012783 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
12012783 switch(it)
2029 {
2030 case -2:
2031 {
2032 for(int32_t i=0; i<MAXLEVELS; i++)
2033 {
2034 if(game->lvlitems[i]&liMAP)
2035 {
2036 return true;
2037 }
2038 }
2039
2040 return false;
2041 }
2042
2043 case -1:
2044 return (game->lvlitems[dlevel]&liMAP)!=0;
2045
2046 default:
2047
2/4
✓ Branch 0 taken 12012783 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12012783 times.
12012783 if(it>=0&&it<MAXLEVELS)
2048 {
2049 12012783 return (game->lvlitems[it]&liMAP)!=0;
2050 }
2051
2052 break;
2053 }
2054
2055 return 0;
2056 }
2057
2058 case itype_compass: //it: -2=any, -1=current level, other=that level
2059 {
2060
1/3
✓ Branch 0 taken 3882589 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3882589 switch(it)
2061 {
2062 case -2:
2063 {
2064 for(int32_t i=0; i<MAXLEVELS; i++)
2065 {
2066 if(game->lvlitems[i]&liCOMPASS)
2067 {
2068 return true;
2069 }
2070 }
2071
2072 return false;
2073 }
2074
2075 case -1:
2076 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2077
2078 default:
2079
2/4
✓ Branch 0 taken 3882589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3882589 times.
✗ Branch 3 not taken.
3882589 if(it>=0&&it<MAXLEVELS)
2080 {
2081 3882589 return (game->lvlitems[it]&liCOMPASS)!=0;
2082 }
2083
2084 break;
2085 }
2086 return 0;
2087 }
2088
2089 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2090 {
2091
1/3
✓ Branch 0 taken 27624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
27624 switch(it)
2092 {
2093 case -2:
2094 {
2095 for(int32_t i=0; i<MAXLEVELS; i++)
2096 {
2097 if(game->lvlitems[i]&liBOSSKEY)
2098 {
2099 return true;
2100 }
2101 }
2102
2103 return false;
2104 }
2105
2106 case -1:
2107 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2108
2109 default:
2110
2/4
✓ Branch 0 taken 27624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27624 times.
27624 if(it>=0&&it<MAXLEVELS)
2111 {
2112 27624 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2113 }
2114 break;
2115 }
2116 return 0;
2117 }
2118
2119 default:
2120 //it=(1<<(it-1));
2121 /*if (item_type>=itype_max)
2122 {
2123 system_pal();
2124 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2125 game_pal();
2126
2127 return false;
2128 }*/
2129 int32_t itemid = getItemID(itemsbuf, item_type, it);
2130
2131 if(itemid == -1)
2132 return false;
2133
2134 return game->get_item(itemid);
2135 }
2136 22449319 }
2137
2138
2139 69865212 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2140 {
2141
9/9
✓ Branch 0 taken 4086346 times.
✓ Branch 1 taken 37174444 times.
✓ Branch 2 taken 4086346 times.
✓ Branch 3 taken 4086346 times.
✓ Branch 4 taken 4086346 times.
✓ Branch 5 taken 4086346 times.
✓ Branch 6 taken 4086346 times.
✓ Branch 7 taken 4086346 times.
✓ Branch 8 taken 4086346 times.
69865212 switch(item_type)
2142 {
2143 case itype_clock:
2144 {
2145 4086346 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2146
2147
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4086346 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4086346 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2148 return itemsbuf[maxid].fam_type;
2149
2150 4086346 return has_item(itype_clock,1) ? 1 : 0;
2151 }
2152
2153 case itype_key:
2154 4086346 return game->get_keys();
2155
2156 case itype_lkey:
2157 4086346 return game->lvlkeys[get_dlevel()];
2158
2159 case itype_magiccontainer:
2160 4086346 return game->get_maxmagic()/game->get_mp_per_block();
2161
2162 case itype_triforcepiece:
2163 {
2164 4086346 int32_t count=0;
2165
2166
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2167 {
2168 2092209152 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2169 2092209152 }
2170
2171 4086346 return count;
2172 }
2173
2174 case itype_map:
2175 {
2176 4086346 int32_t count=0;
2177
2178
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2179 {
2180 2092209152 count+=(game->lvlitems[i]&liMAP)?1:0;
2181 2092209152 }
2182
2183 4086346 return count;
2184 }
2185
2186 case itype_compass:
2187 {
2188 4086346 int32_t count=0;
2189
2190
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2191 {
2192 2092209152 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2193 2092209152 }
2194
2195 4086346 return count;
2196 }
2197
2198 case itype_bosskey:
2199 {
2200 4086346 int32_t count=0;
2201
2202
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2203 {
2204 2092209152 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2205 2092209152 }
2206
2207 4086346 return count;
2208 }
2209
2210 default:
2211 37174444 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2212
2213
2/2
✓ Branch 0 taken 6971052 times.
✓ Branch 1 taken 30203392 times.
37174444 if(maxid == -1)
2214 30203392 return 0;
2215
2216 6971052 return itemsbuf[maxid].fam_type;
2217 }
2218 69865212 }
2219
2220 64438612 int32_t current_item(int32_t item_type) //item currently being used
2221 {
2222 64438612 return current_item(item_type, true);
2223 }
2224
2225 29 std::map<int32_t, int32_t> itemcache;
2226
2227 // Not actually used by anything at the moment...
2228 void removeFromItemCache(int32_t itemid)
2229 {
2230 itemcache.erase(itemid);
2231 }
2232
2233 19096 void flushItemCache()
2234 {
2235 19096 itemcache.clear();
2236
2237 //also fix the active subscreen if items were deleted -DD
2238
1/2
✓ Branch 0 taken 19096 times.
✗ Branch 1 not taken.
19096 if(game != NULL)
2239 {
2240 19096 verifyBothWeapons();
2241 19096 load_Sitems(&QMisc);
2242 19096 }
2243 19096 }
2244
2245 // This is used often, so it should be as direct as possible.
2246 2281827242 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2247 {
2248
2/2
✓ Branch 0 taken 2233022885 times.
✓ Branch 1 taken 48804357 times.
2281827242 if(jinx_check)
2249 {
2250
4/4
✓ Branch 0 taken 31164925 times.
✓ Branch 1 taken 17639432 times.
✓ Branch 2 taken 27758483 times.
✓ Branch 3 taken 3406442 times.
48804357 if(!(HeroSwordClk() || HeroItemClk()))
2251 27758483 jinx_check = false; //not jinxed
2252 48804357 }
2253
4/4
✓ Branch 0 taken 2262423702 times.
✓ Branch 1 taken 19403540 times.
✓ Branch 2 taken 20897290 times.
✓ Branch 3 taken 2241526412 times.
2281827242 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2254 {
2255 2241526412 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2256
2257
2/2
✓ Branch 0 taken 2231777900 times.
✓ Branch 1 taken 9748512 times.
2241526412 if(res != itemcache.end())
2258 2231777900 return res->second;
2259 9748512 }
2260
2261 50049342 int32_t result = -1;
2262 50049342 int32_t highestlevel = -1;
2263
2264
2/2
✓ Branch 0 taken 12812631552 times.
✓ Branch 1 taken 50049342 times.
12862680894 for(int32_t i=0; i<MAXITEMS; i++)
2265 {
2266
5/6
✓ Branch 0 taken 1030627526 times.
✓ Branch 1 taken 11782004026 times.
✓ Branch 2 taken 15409861 times.
✓ Branch 3 taken 1015217665 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15409861 times.
12812631552 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2267 {
2268
4/4
✓ Branch 0 taken 4655389 times.
✓ Branch 1 taken 10754472 times.
✓ Branch 2 taken 1195206 times.
✓ Branch 3 taken 14214655 times.
15409861 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2269 {
2270 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2271
2/2
✓ Branch 0 taken 14214535 times.
✓ Branch 1 taken 120 times.
14214655 if(!checkmagiccost(i))
2272 {
2273
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 108 times.
120 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2274 12 }
2275 14214547 }
2276
6/6
✓ Branch 0 taken 13234243 times.
✓ Branch 1 taken 2175510 times.
✓ Branch 2 taken 229100 times.
✓ Branch 3 taken 1946410 times.
✓ Branch 4 taken 1458492 times.
✓ Branch 5 taken 717018 times.
15409753 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2277 {
2278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 717018 times.
717018 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2279 717018 continue;
2280 }
2281
2282
2/2
✓ Branch 0 taken 223586 times.
✓ Branch 1 taken 14469149 times.
14692735 if(itemsbuf[i].fam_type >= highestlevel)
2283 {
2284 14469149 highestlevel = itemsbuf[i].fam_type;
2285 14469149 result=i;
2286 14469149 }
2287 14692735 }
2288 12811914426 }
2289
2290
2/2
✓ Branch 0 taken 21045874 times.
✓ Branch 1 taken 29003468 times.
50049342 if(!jinx_check) //Can't cache jinx_check results
2291 29003468 itemcache[itemtype] = result;
2292 50049342 return result;
2293 2281827242 }
2294
2295 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2296 2261061951 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2297 {
2298 2261061951 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2299
2/2
✓ Branch 0 taken 28039066 times.
✓ Branch 1 taken 2233022885 times.
2261061951 if(!jinx_check) //If not already a jinx-immune-only check...
2300 {
2301 //And the player IS jinxed...
2302
4/4
✓ Branch 0 taken 2215614958 times.
✓ Branch 1 taken 17407927 times.
✓ Branch 2 taken 3357364 times.
✓ Branch 3 taken 2212257594 times.
2233022885 if(HeroSwordClk() || HeroItemClk())
2303 {
2304 //Then do a jinx-immune-only check here
2305 20765291 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2306 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2307 //Should NOT need a compat rule, as this should always return -1 in old quests.
2308
2/2
✓ Branch 0 taken 974915 times.
✓ Branch 1 taken 19790376 times.
20765291 if(ret2 > -1) return ret2;
2309 19790376 }
2310 2232047970 }
2311 2260087036 return ret;
2312 2261061951 }
2313 14776608 int32_t current_item_power(int32_t itemtype)
2314 {
2315 14776608 int32_t result = current_item_id(itemtype,true);
2316
2/2
✓ Branch 0 taken 11445380 times.
✓ Branch 1 taken 3331228 times.
14776608 return (result<0) ? 0 : itemsbuf[result].power;
2317 }
2318
2319 7 int32_t heart_container_id()
2320 {
2321
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 for(int32_t i=0; i<MAXITEMS; i++)
2322 {
2323
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 196 times.
203 if(itemsbuf[i].family == itype_heartcontainer)
2324 {
2325 7 return i;
2326 }
2327 196 }
2328 return -1;
2329 7 }
2330
2331 4086346 int32_t item_tile_mod()
2332 {
2333 4086346 int32_t tile=0;
2334
2335
2/2
✓ Branch 0 taken 975760 times.
✓ Branch 1 taken 3110586 times.
4086346 if(game->get_bombs())
2336 {
2337 3110586 int32_t itemid = current_item_id(itype_bomb,false);
2338
3/4
✓ Branch 0 taken 3029527 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3029527 times.
3110586 if(itemid > -1 && checkbunny(itemid))
2339 3029527 tile+=itemsbuf[itemid].ltm;
2340 3110586 }
2341
2342
2/2
✓ Branch 0 taken 3032663 times.
✓ Branch 1 taken 1053683 times.
4086346 if(game->get_sbombs())
2343 {
2344 1053683 int32_t itemid = current_item_id(itype_sbomb,false);
2345
3/4
✓ Branch 0 taken 1052255 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1052255 times.
1053683 if(itemid > -1 && checkbunny(itemid))
2346 1052255 tile+=itemsbuf[itemid].ltm;
2347 1053683 }
2348
2349
2/2
✓ Branch 0 taken 3998396 times.
✓ Branch 1 taken 87950 times.
4086346 if(current_item(itype_clock))
2350 {
2351 87950 int32_t itemid =
2352
1/2
✓ Branch 0 taken 87950 times.
✗ Branch 1 not taken.
87950 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2353 ? iClock
2354 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2355
2/4
✓ Branch 0 taken 87950 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 87950 times.
87950 if(itemid > -1 && checkbunny(itemid))
2356 87950 tile+=itemsbuf[itemid].ltm;
2357 87950 }
2358
2359
2/2
✓ Branch 0 taken 3438526 times.
✓ Branch 1 taken 647820 times.
4086346 if(current_item(itype_key))
2360 {
2361 647820 int32_t itemid =
2362
1/2
✓ Branch 0 taken 647820 times.
✗ Branch 1 not taken.
647820 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2363 ? iKey
2364 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2365
2/4
✓ Branch 0 taken 647820 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 647820 times.
647820 if(itemid > -1 && checkbunny(itemid))
2366 647820 tile+=itemsbuf[itemid].ltm;
2367 647820 }
2368
2369
2/2
✓ Branch 0 taken 3927093 times.
✓ Branch 1 taken 159253 times.
4086346 if(current_item(itype_lkey))
2370 {
2371 159253 int32_t itemid =
2372
2/2
✓ Branch 0 taken 158343 times.
✓ Branch 1 taken 910 times.
159253 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2373 ? iLevelKey
2374 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2375
2/4
✓ Branch 0 taken 159253 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 159253 times.
159253 if(itemid > -1 && checkbunny(itemid))
2376 159253 tile+=itemsbuf[itemid].ltm;
2377 159253 }
2378
2379
2/2
✓ Branch 0 taken 886117 times.
✓ Branch 1 taken 3200229 times.
4086346 if(current_item(itype_map))
2380 {
2381 3200229 int32_t itemid =
2382
2/2
✓ Branch 0 taken 3199443 times.
✓ Branch 1 taken 786 times.
3200229 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2383 ? iMap
2384 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2385
2/4
✓ Branch 0 taken 3200229 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3200229 times.
3200229 if(itemid > -1 && checkbunny(itemid))
2386 3200229 tile+=itemsbuf[itemid].ltm;
2387 3200229 }
2388
2389
2/2
✓ Branch 0 taken 807819 times.
✓ Branch 1 taken 3278527 times.
4086346 if(current_item(itype_compass))
2390 {
2391 3278527 int32_t itemid =
2392
2/2
✓ Branch 0 taken 3197468 times.
✓ Branch 1 taken 81059 times.
3278527 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2393 ? iCompass
2394 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2395
2/4
✓ Branch 0 taken 3278527 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3278527 times.
3278527 if(itemid > -1 && checkbunny(itemid))
2396 3278527 tile+=itemsbuf[itemid].ltm;
2397 3278527 }
2398
2399
2/2
✓ Branch 0 taken 2275984 times.
✓ Branch 1 taken 1810362 times.
4086346 if(current_item(itype_bosskey))
2400 {
2401 1810362 int32_t itemid =
2402
1/2
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
1810362 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2403 ? iBossKey
2404 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2405
2/4
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1810362 times.
1810362 if(itemid > -1 && checkbunny(itemid))
2406 1810362 tile+=itemsbuf[itemid].ltm;
2407 1810362 }
2408
2409
2/2
✓ Branch 0 taken 2141126 times.
✓ Branch 1 taken 1945220 times.
4086346 if(current_item(itype_magiccontainer))
2410 {
2411 1945220 int32_t itemid =
2412
2/2
✓ Branch 0 taken 1852005 times.
✓ Branch 1 taken 93215 times.
1945220 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2413 ? iMagicC
2414 93215 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2415
3/4
✓ Branch 0 taken 1945220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 1943350 times.
1945220 if(itemid > -1 && checkbunny(itemid))
2416 1943350 tile+=itemsbuf[itemid].ltm;
2417 1945220 }
2418
2419
2/2
✓ Branch 0 taken 1118041 times.
✓ Branch 1 taken 2968305 times.
4086346 if(current_item(itype_triforcepiece))
2420 {
2421 2968305 int32_t itemid =
2422
1/2
✓ Branch 0 taken 2968305 times.
✗ Branch 1 not taken.
2968305 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2423 ? iTriforce
2424 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2425
2/4
✓ Branch 0 taken 2968305 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2968305 times.
2968305 if(itemid > -1 && checkbunny(itemid))
2426 2968305 tile+=itemsbuf[itemid].ltm;
2427 2968305 }
2428
2429
2/2
✓ Branch 0 taken 4086346 times.
✓ Branch 1 taken 2092209152 times.
2096295498 for(int32_t i=0; i<itype_max; i++)
2430 {
2431
2/2
✓ Branch 0 taken 2035907072 times.
✓ Branch 1 taken 56302080 times.
2092209152 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2432 {
2433
2/2
✓ Branch 0 taken 1099650 times.
✓ Branch 1 taken 55202430 times.
56302080 switch(i)
2434 {
2435 case itype_bomb:
2436 case itype_sbomb:
2437 case itype_clock:
2438 case itype_key:
2439 case itype_lkey:
2440 case itype_map:
2441 case itype_compass:
2442 case itype_bosskey:
2443 case itype_magiccontainer:
2444 case itype_triforcepiece:
2445 1099650 continue; //already handled
2446 }
2447 55202430 }
2448 2091109502 int32_t itemid = current_item_id(i,false);
2449
2/2
✓ Branch 0 taken 2087023156 times.
✓ Branch 1 taken 4086346 times.
2091109502 if(i == itype_shield)
2450 4086346 itemid = getCurrentShield(false);
2451
2452
4/4
✓ Branch 0 taken 59139201 times.
✓ Branch 1 taken 2031970301 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 59038220 times.
2091109502 if(itemid < 0 || !checkbunny(itemid))
2453 2032071282 continue;
2454
2455 59038220 itemdata const& itm = itemsbuf[itemid];
2456
2457
2/2
✓ Branch 0 taken 55529396 times.
✓ Branch 1 taken 3508824 times.
59038220 switch(itm.family)
2458 {
2459 case itype_shield:
2460
1/2
✓ Branch 0 taken 3508824 times.
✗ Branch 1 not taken.
3508824 if(itm.flags & ITEM_FLAG9) //active shield
2461 {
2462 if(!usingActiveShield(itemid))
2463 {
2464 tile+=itm.misc6; //'Inactive PTM'
2465 continue;
2466 }
2467 }
2468 3508824 break;
2469 }
2470
2471 59038220 tile+=itm.ltm;
2472 59038220 }
2473
2474 4086346 return tile;
2475 }
2476
2477 4086346 int32_t bunny_tile_mod()
2478 {
2479
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 4084476 times.
4086346 if(Hero.BunnyClock())
2480 {
2481 1870 return game->get_bunny_ltm();
2482 }
2483 4084476 return 0;
2484 4086346 }
2485
2486 // Hints are drawn on a separate layer to combo reveals.
2487 16332 void draw_lens_under(BITMAP *dest, bool layer)
2488 {
2489 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2490 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2491 //Lens flag 3: Don't show armos/chest/dive items
2492 //Lens flag 4: Show Raft Paths
2493 //Lens flag 5: Show Invisible Enemies
2494
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2495
2496 16332 int32_t strike_hint_table[11]=
2497 {
2498 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2499 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2500 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2501 };
2502
2503 // int32_t page = tmpscr->cpage;
2504 {
2505 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2506 // int32_t temptimer=0;
2507 16332 int32_t tempitem, tempweapon=0;
2508 16332 strike_hint=strike_hint_table[strike_hint_counter];
2509
2510
2/2
✓ Branch 0 taken 15840 times.
✓ Branch 1 taken 492 times.
16332 if(strike_hint_timer>32)
2511 {
2512 492 strike_hint_timer=0;
2513 492 strike_hint_counter=((strike_hint_counter+1)%11);
2514 492 }
2515
2516 16332 ++strike_hint_timer;
2517
2518
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2519 {
2520 2874432 int32_t x = (i & 15) << 4;
2521 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2522 2874432 int32_t tempitemx=-16, tempitemy=-16;
2523 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2524
2525
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2526 {
2527 5748864 int32_t checkflag=0;
2528
2529
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2530 {
2531 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2532 2874432 }
2533 else
2534 {
2535 2874432 checkflag=tmpscr->sflag[i];
2536 }
2537
2538
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2539 {
2540
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2541 {
2542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2543 906 }
2544 else
2545 {
2546 192 checkflag = strike_hint;
2547 }
2548 1098 }
2549
2550
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2551 {
2552 case 0:
2553 case mfZELDA:
2554 case mfPUSHED:
2555 case mfENEMY0:
2556 case mfENEMY1:
2557 case mfENEMY2:
2558 case mfENEMY3:
2559 case mfENEMY4:
2560 case mfENEMY5:
2561 case mfENEMY6:
2562 case mfENEMY7:
2563 case mfENEMY8:
2564 case mfENEMY9:
2565 case mfSINGLE:
2566 case mfSINGLE16:
2567 case mfNOENEMY:
2568 case mfTRAP_H:
2569 case mfTRAP_V:
2570 case mfTRAP_4:
2571 case mfTRAP_LR:
2572 case mfTRAP_UD:
2573 case mfNOGROUNDENEMY:
2574 case mfNOBLOCKS:
2575 case mfSCRIPT1:
2576 case mfSCRIPT2:
2577 case mfSCRIPT3:
2578 case mfSCRIPT4:
2579 case mfSCRIPT5:
2580 case mfSCRIPT6:
2581 case mfSCRIPT7:
2582 case mfSCRIPT8:
2583 case mfSCRIPT9:
2584 case mfSCRIPT10:
2585 case mfSCRIPT11:
2586 case mfSCRIPT12:
2587 case mfSCRIPT13:
2588 case mfSCRIPT14:
2589 case mfSCRIPT15:
2590 case mfSCRIPT16:
2591 case mfSCRIPT17:
2592 case mfSCRIPT18:
2593 case mfSCRIPT19:
2594 case mfSCRIPT20:
2595 case mfPITHOLE:
2596 case mfPITFALLFLOOR:
2597 case mfLAVA:
2598 case mfICE:
2599 case mfICEDAMAGE:
2600 case mfDAMAGE1:
2601 case mfDAMAGE2:
2602 case mfDAMAGE4:
2603 case mfDAMAGE8:
2604 case mfDAMAGE16:
2605 case mfDAMAGE32:
2606 case mfFREEZEALL:
2607 case mfFREZEALLANSFFCS:
2608 case mfFREEZEFFCSOLY:
2609 case mfSCRITPTW1TRIG:
2610 case mfSCRITPTW2TRIG:
2611 case mfSCRITPTW3TRIG:
2612 case mfSCRITPTW4TRIG:
2613 case mfSCRITPTW5TRIG:
2614 case mfSCRITPTW6TRIG:
2615 case mfSCRITPTW7TRIG:
2616 case mfSCRITPTW8TRIG:
2617 case mfSCRITPTW9TRIG:
2618 case mfSCRITPTW10TRIG:
2619 case mfTROWEL:
2620 case mfTROWELNEXT:
2621 case mfTROWELSPECIALITEM:
2622 case mfSLASHPOT:
2623 case mfLIFTPOT:
2624 case mfLIFTORSLASH:
2625 case mfLIFTROCK:
2626 case mfLIFTROCKHEAVY:
2627 case mfDROPITEM:
2628 case mfSPECIALITEM:
2629 case mfDROPKEY:
2630 case mfDROPLKEY:
2631 case mfDROPCOMPASS:
2632 case mfDROPMAP:
2633 case mfDROPBOSSKEY:
2634 case mfSPAWNNPC:
2635 case mfSWITCHHOOK:
2636 case mfSIDEVIEWLADDER:
2637 case mfSIDEVIEWPLATFORM:
2638 case mfNOENEMYSPAWN:
2639 case mfENEMYALL:
2640 case mfNOMIRROR:
2641 case mfUNSAFEGROUND:
2642 case mf168:
2643 case mf169:
2644 case mf170:
2645 case mf171:
2646 case mf172:
2647 case mf173:
2648 case mf174:
2649 case mf175:
2650 case mf176:
2651 case mf177:
2652 case mf178:
2653 case mf179:
2654 case mf180:
2655 case mf181:
2656 case mf182:
2657 case mf183:
2658 case mf184:
2659 case mf185:
2660 case mf186:
2661 case mf187:
2662 case mf188:
2663 case mf189:
2664 case mf190:
2665 case mf191:
2666 case mf192:
2667 case mf193:
2668 case mf194:
2669 case mf195:
2670 case mf196:
2671 case mf197:
2672 case mf198:
2673 case mf199:
2674 case mf200:
2675 case mf201:
2676 case mf202:
2677 case mf203:
2678 case mf204:
2679 case mf205:
2680 case mf206:
2681 case mf207:
2682 case mf208:
2683 case mf209:
2684 case mf210:
2685 case mf211:
2686 case mf212:
2687 case mf213:
2688 case mf214:
2689 case mf215:
2690 case mf216:
2691 case mf217:
2692 case mf218:
2693 case mf219:
2694 case mf220:
2695 case mf221:
2696 case mf222:
2697 case mf223:
2698 case mf224:
2699 case mf225:
2700 case mf226:
2701 case mf227:
2702 case mf228:
2703 case mf229:
2704 case mf230:
2705 case mf231:
2706 case mf232:
2707 case mf233:
2708 case mf234:
2709 case mf235:
2710 case mf236:
2711 case mf237:
2712 case mf238:
2713 case mf239:
2714 case mf240:
2715 case mf241:
2716 case mf242:
2717 case mf243:
2718 case mf244:
2719 case mf245:
2720 case mf246:
2721 case mf247:
2722 case mf248:
2723 case mf249:
2724 case mf250:
2725 case mf251:
2726 case mf252:
2727 case mf253:
2728 case mf254:
2729 case mfEXTENDED:
2730 5706470 break;
2731
2732 case mfPUSHUD:
2733 case mfPUSHLR:
2734 case mfPUSH4:
2735 case mfPUSHU:
2736 case mfPUSHD:
2737 case mfPUSHL:
2738 case mfPUSHR:
2739 case mfPUSHUDNS:
2740 case mfPUSHLRNS:
2741 case mfPUSH4NS:
2742 case mfPUSHUNS:
2743 case mfPUSHDNS:
2744 case mfPUSHLNS:
2745 case mfPUSHRNS:
2746 case mfPUSHUDINS:
2747 case mfPUSHLRINS:
2748 case mfPUSH4INS:
2749 case mfPUSHUINS:
2750 case mfPUSHDINS:
2751 case mfPUSHLINS:
2752 case mfPUSHRINS:
2753
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2754
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2755 {
2756 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2757 }
2758
2759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2760
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2761 {
2762
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2763 {
2764
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2765 {
2766 case cPUSH_HEAVY:
2767 case cPUSH_HW:
2768 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2769 72 tempitemx=x, tempitemy=y;
2770
2771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2772 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2773
2774 72 break;
2775
2776 case cPUSH_HEAVY2:
2777 case cPUSH_HW2:
2778 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2779 63 tempitemx=x, tempitemy=y;
2780
2781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2782 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2783
2784 63 break;
2785 }
2786 1032 }
2787 2438 }
2788
2789 3148 break;
2790
2791 case mfWHISTLE:
2792
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2793 {
2794 tempitem=getItemID(itemsbuf,itype_whistle,1);
2795
2796 if(tempitem<0) break;
2797
2798 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2799 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2800 {
2801 tempitemx=x;
2802 tempitemy=y;
2803 }
2804
2805 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2806 }
2807
2808 2418 break;
2809
2810 //Why is this here?
2811 case mfFAIRY:
2812 case mfMAGICFAIRY:
2813 case mfALLFAIRY:
2814 if(hints)
2815 {
2816 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2817
2818 if(tempitem < 0) break;
2819
2820 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2821 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2822 {
2823 tempitemx=x;
2824 tempitemy=y;
2825 }
2826
2827 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2828 }
2829
2830 break;
2831
2832 case mfANYFIRE:
2833
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2834 {
2835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2836 252 }
2837 else
2838 {
2839 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2840
2841
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2842
2843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2844
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2845 {
2846 189 tempitemx=x;
2847 189 tempitemy=y;
2848 189 }
2849
2850 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2851 }
2852
2853 504 break;
2854
2855 case mfSTRONGFIRE:
2856 if(!hints)
2857 {
2858 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2859 }
2860 else
2861 {
2862 tempitem=getItemID(itemsbuf,itype_candle,2);
2863
2864 if(tempitem<0) break;
2865
2866 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2867 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2868 {
2869 tempitemx=x;
2870 tempitemy=y;
2871 }
2872
2873 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2874 }
2875
2876 break;
2877
2878 case mfMAGICFIRE:
2879 if(!hints)
2880 {
2881 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2882 }
2883 else
2884 {
2885 tempitem=getItemID(itemsbuf,itype_wand,1);
2886
2887 if(tempitem<0) break;
2888
2889 tempweapon=wFire;
2890
2891 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2892 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2893 {
2894 tempitemx=x;
2895 tempitemy=y;
2896 }
2897 else
2898 {
2899 tempweaponx=x;
2900 tempweapony=y;
2901 }
2902
2903 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2904 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2905 }
2906
2907 break;
2908
2909 case mfDIVINEFIRE:
2910 if(!hints)
2911 {
2912 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2913 }
2914 else
2915 {
2916 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2917
2918 if(tempitem<0) break;
2919
2920 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2921 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2922 {
2923 tempitemx=x;
2924 tempitemy=y;
2925 }
2926
2927 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2928 }
2929
2930 break;
2931
2932 case mfARROW:
2933
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2934 {
2935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2936 732 }
2937 else
2938 {
2939 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2940
2941
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2942
2943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2944
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2945 {
2946 61 tempitemx=x;
2947 61 tempitemy=y;
2948 61 }
2949
2950 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2951 }
2952
2953 814 break;
2954
2955 case mfSARROW:
2956 if(!hints)
2957 {
2958 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2959 }
2960 else
2961 {
2962 tempitem=getItemID(itemsbuf,itype_arrow,2);
2963
2964 if(tempitem<0) break;
2965
2966 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2967 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2968 {
2969 tempitemx=x;
2970 tempitemy=y;
2971 }
2972
2973 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2974 }
2975
2976 break;
2977
2978 case mfGARROW:
2979 if(!hints)
2980 {
2981 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2982 }
2983 else
2984 {
2985 tempitem=getItemID(itemsbuf,itype_arrow,3);
2986
2987 if(tempitem<0) break;
2988
2989 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2990 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2991 {
2992 tempitemx=x;
2993 tempitemy=y;
2994 }
2995
2996 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2997 }
2998
2999 break;
3000
3001 case mfBOMB:
3002
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3003 {
3004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3005 16 }
3006 else
3007 {
3008 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3009 17 tempweapon = wLitBomb;
3010
3011 //if (tempitem<0) break;
3012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3013
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3014 {
3015 12 tempweaponx=x;
3016 12 tempweapony=y;
3017 12 }
3018
3019 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3020 }
3021
3022 33 break;
3023
3024 case mfSBOMB:
3025
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3026 {
3027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3028 48 }
3029 else
3030 {
3031 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3032 //if (tempitem<0) break;
3033 48 tempweapon = wLitSBomb;
3034
3035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3036
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3037 {
3038 36 tempweaponx=x;
3039 36 tempweapony=y;
3040 36 }
3041
3042 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3043 }
3044
3045 96 break;
3046
3047 case mfARMOS_SECRET:
3048
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3049 {
3050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3051 12 }
3052 24 break;
3053
3054 case mfBRANG:
3055
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3056 {
3057 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3058 }
3059 else
3060 {
3061 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3062
3063
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3064
3065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3066
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3067 {
3068 4 tempitemx=x;
3069 4 tempitemy=y;
3070 4 }
3071
3072 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3073 }
3074
3075 5 break;
3076
3077 case mfMBRANG:
3078 if(!hints)
3079 {
3080 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3081 }
3082 else
3083 {
3084 tempitem=getItemID(itemsbuf,itype_brang,2);
3085
3086 if(tempitem<0) break;
3087
3088 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3089 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3090 {
3091 tempitemx=x;
3092 tempitemy=y;
3093 }
3094
3095 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3096 }
3097
3098 break;
3099
3100 case mfFBRANG:
3101 if(!hints)
3102 {
3103 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3104 }
3105 else
3106 {
3107 tempitem=getItemID(itemsbuf,itype_brang,3);
3108
3109 if(tempitem<0) break;
3110
3111 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3112 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3113 {
3114 tempitemx=x;
3115 tempitemy=y;
3116 }
3117
3118 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3119 }
3120
3121 break;
3122
3123 case mfWANDMAGIC:
3124 if(!hints)
3125 {
3126 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3127 }
3128 else
3129 {
3130 tempitem=getItemID(itemsbuf,itype_wand,1);
3131
3132 if(tempitem<0) break;
3133
3134 tempweapon=itemsbuf[tempitem].wpn3;
3135
3136 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3137 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3138 {
3139 tempitemx=x;
3140 tempitemy=y;
3141 }
3142 else
3143 {
3144 tempweaponx=x;
3145 tempweapony=y;
3146 --lens_hint_weapon[wMagic][4];
3147
3148 if(lens_hint_weapon[wMagic][4]<-8)
3149 {
3150 lens_hint_weapon[wMagic][4]=8;
3151 }
3152 }
3153
3154 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3155 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3156 }
3157
3158 break;
3159
3160 case mfREFMAGIC:
3161
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3162 {
3163 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3164 }
3165 else
3166 {
3167 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3168
3169
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3170
3171 16 tempweapon=ewMagic;
3172
3173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3174
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3175 {
3176 13 tempitemx=x;
3177 13 tempitemy=y;
3178 13 }
3179 else
3180 {
3181 3 tempweaponx=x;
3182 3 tempweapony=y;
3183
3184
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3185 {
3186 1 --lens_hint_weapon[ewMagic][4];
3187 1 }
3188 else
3189 {
3190 2 ++lens_hint_weapon[ewMagic][4];
3191 }
3192
3193
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3194 {
3195 lens_hint_weapon[ewMagic][2]=up;
3196 }
3197
3198
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3199 {
3200 2 lens_hint_weapon[ewMagic][2]=down;
3201 2 }
3202 }
3203
3204 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3205 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3206 }
3207
3208 16 break;
3209
3210 case mfREFFIREBALL:
3211
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3212 {
3213 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3214 }
3215 else
3216 {
3217 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3218
3219
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3220
3221 16 tempweapon=ewFireball;
3222
3223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3224
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3225 {
3226 12 tempitemx=x;
3227 12 tempitemy=y;
3228 12 tempweaponx=x;
3229 12 tempweapony=y;
3230 12 ++lens_hint_weapon[ewFireball][3];
3231
3232
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3233 {
3234 1 lens_hint_weapon[ewFireball][3]=-8;
3235 1 lens_hint_weapon[ewFireball][4]=8;
3236 1 }
3237
3238
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3239 {
3240 8 ++lens_hint_weapon[ewFireball][4];
3241 8 }
3242 else
3243 {
3244 4 --lens_hint_weapon[ewFireball][4];
3245 }
3246 12 }
3247
3248 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3249 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3250 }
3251
3252 16 break;
3253
3254 case mfSWORD:
3255
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3256 {
3257 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3258 }
3259 else
3260 {
3261 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3262
3263
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3264
3265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3266
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3267 {
3268 5 tempitemx=x;
3269 5 tempitemy=y;
3270 5 }
3271
3272 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3273 }
3274
3275 7 break;
3276
3277 case mfWSWORD:
3278 if(!hints)
3279 {
3280 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3281 }
3282 else
3283 {
3284 tempitem=getItemID(itemsbuf,itype_sword,2);
3285
3286 if(tempitem<0) break;
3287
3288 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3289 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3290 {
3291 tempitemx=x;
3292 tempitemy=y;
3293 }
3294
3295 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3296 }
3297
3298 break;
3299
3300 case mfMSWORD:
3301 if(!hints)
3302 {
3303 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3304 }
3305 else
3306 {
3307 tempitem=getItemID(itemsbuf,itype_sword,3);
3308
3309 if(tempitem<0) break;
3310
3311 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3312 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3313 {
3314 tempitemx=x;
3315 tempitemy=y;
3316 }
3317
3318 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3319 }
3320
3321 break;
3322
3323 case mfXSWORD:
3324 if(!hints)
3325 {
3326 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3327 }
3328 else
3329 {
3330 tempitem=getItemID(itemsbuf,itype_sword,4);
3331
3332 if(tempitem<0) break;
3333
3334 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3335 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3336 {
3337 tempitemx=x;
3338 tempitemy=y;
3339 }
3340
3341 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3342 }
3343
3344 break;
3345
3346 case mfSWORDBEAM:
3347
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3348 {
3349 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3350 }
3351 else
3352 {
3353 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3354
3355
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3356
3357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3358
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3359 {
3360 11 tempitemx=x;
3361 11 tempitemy=y;
3362 11 }
3363
3364 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3365 }
3366
3367 16 break;
3368
3369 case mfWSWORDBEAM:
3370 if(!hints)
3371 {
3372 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3373 }
3374 else
3375 {
3376 tempitem=getItemID(itemsbuf,itype_sword,2);
3377
3378 if(tempitem<0) break;
3379
3380 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3381 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3382 {
3383 tempitemx=x;
3384 tempitemy=y;
3385 }
3386
3387 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3388 }
3389
3390 break;
3391
3392 case mfMSWORDBEAM:
3393 if(!hints)
3394 {
3395 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3396 }
3397 else
3398 {
3399 tempitem=getItemID(itemsbuf,itype_sword,3);
3400
3401 if(tempitem<0) break;
3402
3403 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3404 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3405 {
3406 tempitemx=x;
3407 tempitemy=y;
3408 }
3409
3410 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3411 }
3412
3413 break;
3414
3415 case mfXSWORDBEAM:
3416 if(!hints)
3417 {
3418 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3419 }
3420 else
3421 {
3422 tempitem=getItemID(itemsbuf,itype_sword,4);
3423
3424 if(tempitem<0) break;
3425
3426 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3427 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3428 {
3429 tempitemx=x;
3430 tempitemy=y;
3431 }
3432
3433 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3434 }
3435
3436 break;
3437
3438 case mfHOOKSHOT:
3439
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3440 {
3441 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3442 }
3443 else
3444 {
3445 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3446
3447
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3448
3449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3450
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3451 {
3452 12 tempitemx=x;
3453 12 tempitemy=y;
3454 12 }
3455
3456 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3457 }
3458
3459 17 break;
3460
3461 case mfWAND:
3462
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3463 {
3464 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3465 }
3466 else
3467 {
3468 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3469
3470
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3471
3472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3473
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3474 {
3475 28 tempitemx=x;
3476 28 tempitemy=y;
3477 28 }
3478
3479 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3480 }
3481
3482 35 break;
3483
3484 case mfHAMMER:
3485
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3486 {
3487 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3488 }
3489 else
3490 {
3491 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3492
3493
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3494
3495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3496
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3497 {
3498 13 tempitemx=x;
3499 13 tempitemy=y;
3500 13 }
3501
3502 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3503 }
3504
3505 17 break;
3506
3507 case mfARMOS_ITEM:
3508 case mfDIVE_ITEM:
3509
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3510 {
3511 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3512 2064 }
3513 2064 break;
3514
3515 case 16:
3516 case 17:
3517 case 18:
3518 case 19:
3519 case 20:
3520 case 21:
3521 case 22:
3522 case 23:
3523 case 24:
3524 case 25:
3525 case 26:
3526 case 27:
3527 case 28:
3528 case 29:
3529 case 30:
3530 case 31:
3531
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3533 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3534
3535 3618 break;
3536 case mfSECRETSNEXT:
3537 if(!hints)
3538 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3539 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3540
3541 break;
3542
3543 case mfSTRIKE:
3544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3545 {
3546 906 goto special;
3547 }
3548 else
3549 {
3550 break;
3551 }
3552
3553 28640 default: goto special;
3554
3555 special:
3556
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3557 {
3558
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3559 {
3560 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3561 4913 }
3562 6549 }
3563
3564 29546 break;
3565 }
3566 5748864 }
3567 2874432 }
3568
3569
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3570 {
3571
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3572 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3573
3574
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3575 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3576
3577
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3578 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3579
3580
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3581 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3582
3583
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3584 {
3585 43 showbombeddoor(dest, 0);
3586 43 }
3587
3588
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3589 {
3590 39 showbombeddoor(dest, 1);
3591 39 }
3592
3593
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3594 {
3595 showbombeddoor(dest, 2);
3596 }
3597
3598
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3599 {
3600 37 showbombeddoor(dest, 3);
3601 37 }
3602 8166 }
3603
3604
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3605 {
3606
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3607 {
3608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3609 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3610 1123 }
3611 else
3612 {
3613
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3614 {
3615 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3616 48 int32_t tempitemx=-16;
3617 48 int32_t tempitemy=-16;
3618
3619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3620
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3621 {
3622 24 tempitemx=tmpscr->stairx;
3623 24 tempitemy=tmpscr->stairy+playing_field_offset;
3624 24 }
3625
3626 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3627 48 }
3628 }
3629 2034 }
3630 }
3631 16332 }
3632
3633 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3634
3635 7997 void draw_lens_over()
3636 {
3637 // Oh, what the heck.
3638 static BITMAP *lens_scr = NULL;
3639 static int32_t last_width = -1;
3640 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3641
3642 // Only redraw the circle if the size has changed
3643
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 5 times.
7997 if(width != last_width)
3644 {
3645
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(lens_scr == NULL)
3646 {
3647 5 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3648 5 }
3649
3650 5 clear_to_color(lens_scr, BLACK);
3651 5 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3652 5 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3653 5 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3654 5 last_width=width;
3655 5 }
3656
3657 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3658 7997 }
3659
3660 //----------------------------------------------------------------
3661
3662 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3663 {
3664 //recreating a big bitmap every frame is highly sluggish.
3665
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3666 30701 clear_to_color(wavebuf, BLACK);
3667 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3668
3669 int32_t ofs;
3670 // int32_t amplitude=8;
3671 // int32_t wavelength=4;
3672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3673
3/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3674 30701 int32_t amp2=168;
3675
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3676 30701 int32_t i=frame%amp2;
3677
3678
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3679 {
3680
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3681 {
3682 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3683 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3684 }
3685 else
3686 {
3687 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3688 }
3689
3690
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3691 {
3692
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3693 {
3694 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3695 1320388608 }
3696 5157768 }
3697 5157768 }
3698 30701 }
3699
3700 2832 void draw_fuzzy(int32_t fuzz)
3701 // draws from right half of scrollbuf to framebuf
3702 {
3703 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3704 byte *start, *si, *di;
3705
3706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2832 times.
2832 if(fuzz<1)
3707 fuzz = 1;
3708
3709 2832 xstep = 128%fuzz;
3710
3711
2/2
✓ Branch 0 taken 590 times.
✓ Branch 1 taken 2242 times.
2832 if(xstep > 0)
3712 2242 xstep = fuzz-xstep;
3713
3714 2832 ystep = 112%fuzz;
3715
3716
2/2
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 2006 times.
2832 if(ystep > 0)
3717 2006 ystep = fuzz-ystep;
3718
3719 2832 firsty = 1;
3720
3721
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 102188 times.
105020 for(y=0; y<224;)
3722 {
3723 102188 start = &(scrollbuf->line[y][256]);
3724
3725
4/4
✓ Branch 0 taken 100772 times.
✓ Branch 1 taken 635784 times.
✓ Branch 2 taken 634368 times.
✓ Branch 3 taken 102188 times.
736556 for(dy=0; dy<ystep && dy+y<224; dy++)
3726 {
3727 634368 si = start;
3728 634368 di = &(framebuf->line[y+dy][0]);
3729 634368 i = xstep;
3730 634368 firstx = 1;
3731
3732
2/2
✓ Branch 0 taken 162398208 times.
✓ Branch 1 taken 634368 times.
163032576 for(dx=0; dx<256; dx++)
3733 {
3734 162398208 *(di++) = *si;
3735
3736
2/2
✓ Branch 0 taken 136838464 times.
✓ Branch 1 taken 25559744 times.
162398208 if(++i >= fuzz)
3737 {
3738
2/2
✓ Branch 0 taken 24925376 times.
✓ Branch 1 taken 634368 times.
25559744 if(!firstx)
3739 24925376 si += fuzz;
3740 else
3741 {
3742 634368 si += fuzz-xstep;
3743 634368 firstx = 0;
3744 }
3745
3746 25559744 i = 0;
3747 25559744 }
3748 162398208 }
3749 634368 }
3750
3751
2/2
✓ Branch 0 taken 99356 times.
✓ Branch 1 taken 2832 times.
102188 if(!firsty)
3752 99356 y += fuzz;
3753 else
3754 {
3755 2832 y += ystep;
3756 2832 ystep = fuzz;
3757 2832 firsty = 0;
3758 }
3759 }
3760 2832 }
3761
3762 6510665 void updatescr(bool allowwavy)
3763 {
3764
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 6510636 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
6510665 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3765
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 6510636 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
6510665 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3766
3767
2/2
✓ Branch 0 taken 6484961 times.
✓ Branch 1 taken 25704 times.
6510665 if(toogam)
3768 {
3769 25704 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3770 25704 }
3771
3772
1/2
✓ Branch 0 taken 6510665 times.
✗ Branch 1 not taken.
6510665 if(Showpal)
3773 dump_pal(framebuf);
3774
3775
2/2
✓ Branch 0 taken 6428643 times.
✓ Branch 1 taken 82022 times.
6510665 if(!Playing)
3776 82022 black_opening_count=0;
3777
3778
2/2
✓ Branch 0 taken 6472715 times.
✓ Branch 1 taken 37950 times.
6510665 if(black_opening_count<0) //shape is opening up
3779 {
3780 37950 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3781
3782
2/4
✓ Branch 0 taken 37950 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37950 times.
37950 if(Advance||(!Paused))
3783 {
3784 37950 ++black_opening_count;
3785 37950 }
3786 37950 }
3787
2/2
✓ Branch 0 taken 6458459 times.
✓ Branch 1 taken 14256 times.
6472715 else if(black_opening_count>0) //shape is closing
3788 {
3789 14256 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3790
3791
2/4
✓ Branch 0 taken 14256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14256 times.
14256 if(Advance||(!Paused))
3792 {
3793 14256 --black_opening_count;
3794 14256 }
3795 14256 }
3796
3797
3/4
✓ Branch 0 taken 6459250 times.
✓ Branch 1 taken 51415 times.
✓ Branch 2 taken 6459250 times.
✗ Branch 3 not taken.
6510665 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3798 {
3799 black_opening_shape = bosCIRCLE;
3800 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3801 refreshTints();
3802 refreshpal=true;
3803 }
3804
3805
2/2
✓ Branch 0 taken 6298112 times.
✓ Branch 1 taken 212553 times.
6510665 if(refreshpal)
3806 {
3807 212553 refreshpal=false;
3808 212553 RAMpal[253] = _RGB(0,0,0);
3809 212553 RAMpal[254] = _RGB(63,63,63);
3810 212553 hw_palette = &RAMpal;
3811 212553 update_hw_pal = true;
3812
3813 212553 create_rgb_table(&rgb_table, RAMpal, NULL);
3814 212553 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3815 212553 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3816
3817
2/2
✓ Branch 0 taken 54413568 times.
✓ Branch 1 taken 212553 times.
54626121 for(int32_t q=0; q<PAL_SIZE; q++)
3818 {
3819 54413568 trans_table2.data[0][q] = q;
3820 54413568 trans_table2.data[q][q] = q;
3821 54413568 }
3822 212553 }
3823
3824 6510665 bool clearwavy = (wavy <= 0);
3825
3826
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 6503420 times.
6510665 if(wavy <= 0)
3827 {
3828 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3829 6503420 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3830 6503420 }
3831
3832 6510665 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3833
3834
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 6479714 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
6510665 if(wavy && Playing && allowwavy)
3835 {
3836 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3837 30701 }
3838
3839
2/2
✓ Branch 0 taken 6503420 times.
✓ Branch 1 taken 7245 times.
6510665 if(clearwavy)
3840 6503420 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3841
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3842 7245 wavy--; // Wavy was set by a script. Decrement it.
3843
3844
5/6
✓ Branch 0 taken 6428643 times.
✓ Branch 1 taken 82022 times.
✓ Branch 2 taken 125857 times.
✓ Branch 3 taken 6302786 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 125857 times.
6510665 if(Playing && msgpos && !screenscrolling)
3845 {
3846
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_bg_display_buf->clip))
3847 125857 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3848
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_portrait_display_buf->clip))
3849 125857 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3850
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_txt_display_buf->clip))
3851 125857 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3852 125857 }
3853
3854 /*
3855 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3856 {
3857 BITMAP* subBmp = 0;
3858 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3859 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3860 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3861 destroy_bitmap(subBmp);
3862 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3863 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3864 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3865 }
3866 */
3867
3868
2/2
✓ Branch 0 taken 6485486 times.
✓ Branch 1 taken 25179 times.
6510665 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3869
3870
2/2
✓ Branch 0 taken 6485486 times.
✓ Branch 1 taken 25179 times.
6510665 if(nosubscr)
3871 {
3872 25179 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3873 25179 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3874 25179 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3875 25179 }
3876
3877 //TODO: Optimize blit 'overcalls' -Gleeok
3878
2/2
✓ Branch 0 taken 25179 times.
✓ Branch 1 taken 6485486 times.
6510665 BITMAP *source = nosubscr ? panorama : wavybuf;
3879 6510665 blit(source,framebuf,0,0,0,0,256,224);
3880
3881 6510665 update_hw_screen();
3882 6510665 }
3883
3884 //----------------------------------------------------------------
3885
3886 PALETTE sys_pal;
3887
3888 int32_t onGUISnapshot()
3889 {
3890 char buf[200];
3891 int32_t num=0;
3892 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3893 do
3894 {
3895 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3896 }
3897 while(num<99999 && exists(buf));
3898
3899 BITMAP *b = create_bitmap_ex(8,resx,resy);
3900
3901 if(b)
3902 {
3903 if(MenuOpen)
3904 {
3905 //Cannot load game's palette while GUI elements are in focus. -Z
3906 //If there is a way to do this, then I have missed it.
3907 /*
3908 game_pal();
3909 RAMpal[253] = _RGB(0,0,0);
3910 RAMpal[254] = _RGB(63,63,63);
3911 zc_set_palette_range(RAMpal,0,255,false);
3912 memcpy(RAMpal, snappal, sizeof(snappal));
3913 create_rgb_table(&rgb_table, RAMpal, NULL);
3914 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3915 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3916
3917 for(int32_t q=0; q<PAL_SIZE; q++)
3918 {
3919 trans_table2.data[0][q] = q;
3920 trans_table2.data[q][q] = q;
3921 }
3922 */
3923 //ringcolor(false);
3924 //get_palette(RAMpal);
3925 blit(screen,b,0,0,0,0,resx,resy);
3926 //al_trace("Menu Open\n");
3927 //game_pal();
3928 //PALETTE temppal;
3929 //get_palette(temppal);
3930 //system_pal();
3931 save_bitmap(buf,b,sys_pal);
3932 //save_bitmap(buf,b,RAMpal);
3933 //save_bitmap(buf,b,snappal);
3934 }
3935 else
3936 {
3937 blit(screen,b,0,0,0,0,resx,resy);
3938 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3939 }
3940 destroy_bitmap(b);
3941 }
3942
3943 return D_O_K;
3944 }
3945
3946 int32_t onNonGUISnapshot()
3947 {
3948 PALETTE temppal;
3949 get_palette(temppal);
3950 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3951
3952 char buf[200];
3953 int32_t num=0;
3954
3955 do
3956 {
3957 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3958 }
3959 while(num<99999 && exists(buf));
3960
3961 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3962
3963 return D_O_K;
3964 }
3965
3966 int32_t onSnapshot()
3967 {
3968 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3969 {
3970 onGUISnapshot();
3971 }
3972 else
3973 {
3974 onNonGUISnapshot();
3975 }
3976
3977 return D_O_K;
3978 }
3979
3980 int32_t onSaveMapPic()
3981 {
3982 int32_t mapres2 = 0;
3983 char buf[200];
3984 int32_t num=0;
3985 mapscr tmpscr_b[2];
3986 mapscr tmpscr_c[6];
3987 BITMAP* _screen_draw_buffer = NULL;
3988 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3989 set_clip_state(_screen_draw_buffer,1);
3990
3991 for(int32_t i=0; i<6; ++i)
3992 {
3993 tmpscr_c[i] = tmpscr2[i];
3994 tmpscr2[i].zero_memory();
3995
3996 if(i>=2)
3997 {
3998 continue;
3999 }
4000
4001 tmpscr_b[i] = tmpscr[i];
4002 tmpscr[i].zero_memory();
4003 }
4004
4005 do
4006 {
4007 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4008 }
4009 while(num<99999 && exists(buf));
4010
4011 BITMAP* mappic = NULL;
4012
4013
4014 bool done=false, redraw=true;
4015
4016 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4017
4018 if(!mappic)
4019 {
4020 system_pal();
4021 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4022 game_pal();
4023 return D_O_K;;
4024 }
4025
4026 // draw the map
4027 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4028
4029 for(int32_t y=0; y<8; y++)
4030 {
4031 for(int32_t x=0; x<16; x++)
4032 {
4033 if(!displayOnMap(x, y))
4034 {
4035 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4036 }
4037 else
4038 {
4039 int32_t s = (y<<4) + x;
4040 loadscr2(1,s,-1);
4041
4042 for(int32_t i=0; i<6; i++)
4043 {
4044 if(tmpscr[1].layermap[i]<=0)
4045 continue;
4046
4047 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4048 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4049 {
4050 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4051
4052 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4053 }
4054 }
4055
4056 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4057
4058 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4059
4060 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4061 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4062
4063 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4064
4065 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4066 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4067 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4068 {
4069 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4070 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4071 }
4072 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4073
4074 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4075
4076 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4077 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4078 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4079 {
4080 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4081 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4082 }
4083 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4084 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4085
4086 }
4087
4088 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4089 }
4090 }
4091
4092 for(int32_t i=0; i<6; ++i)
4093 {
4094 tmpscr2[i]=tmpscr_c[i];
4095
4096 if(i>=2)
4097 {
4098 continue;
4099 }
4100
4101 tmpscr[i]=tmpscr_b[i];
4102 }
4103
4104 save_bitmap(buf,mappic,RAMpal);
4105 destroy_bitmap(mappic);
4106 destroy_bitmap(_screen_draw_buffer);
4107 return D_O_K;
4108 }
4109
4110 /*
4111 int32_t onSaveMapPic()
4112 {
4113 BITMAP* mappic = NULL;
4114 BITMAP* _screen_draw_buffer = NULL;
4115 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4116 int32_t mapres2 = 0;
4117 char buf[20];
4118 int32_t num=0;
4119 set_clip_state(_screen_draw_buffer,1);
4120 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4121
4122 do
4123 {
4124 sprintf(buf, "zelda%03d.png", ++num);
4125 }
4126 while(num<999 && exists(buf));
4127
4128 // if(!mappic) {
4129 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4130
4131 if(!mappic)
4132 {
4133 system_pal();
4134 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4135 game_pal();
4136 return D_O_K;
4137 }
4138
4139 // }
4140
4141 int32_t layermap, layerscreen;
4142 int32_t x2=0;
4143
4144 // draw the map
4145 for(int32_t y=0; y<8; y++)
4146 {
4147 for(int32_t x=0; x<16; x++)
4148 {
4149 int32_t s = (y<<4) + x;
4150
4151 if(!displayOnMap(x, y))
4152 {
4153 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4154 }
4155 else
4156 {
4157 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4158 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4159
4160 for(int32_t k=0; k<4; k++)
4161 {
4162 if(k==2)
4163 {
4164 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4165 }
4166
4167 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4168
4169 if(layermap>-1)
4170 {
4171 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4172
4173 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4174 {
4175 for(int32_t i=0; i<176; i++)
4176 {
4177 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4178 }
4179 }
4180 else
4181 {
4182 for(int32_t i=0; i<176; i++)
4183 {
4184 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4185 }
4186 }
4187 }
4188 }
4189
4190 for(int32_t i=0; i<176; i++)
4191 {
4192 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4193 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4194 {
4195 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4196 }
4197 }
4198
4199 for(int32_t k=4; k<6; k++)
4200 {
4201 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4202
4203 if(layermap>-1)
4204 {
4205 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4206
4207 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4208 {
4209 for(int32_t i=0; i<176; i++)
4210 {
4211 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4212 }
4213 }
4214 else
4215 {
4216 for(int32_t i=0; i<176; i++)
4217 {
4218 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4219 }
4220 }
4221 }
4222 }
4223 }
4224
4225 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4226 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4227 }
4228
4229 }
4230
4231 save_bitmap(buf,mappic,RAMpal);
4232 destroy_bitmap(mappic);
4233 destroy_bitmap(_screen_draw_buffer);
4234 return D_O_K;
4235 }
4236 */
4237
4238 14 void f_Quit(int32_t type)
4239 {
4240
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4241 return;
4242
4243 14 bool from_menu = is_sys_pal;
4244
4245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4246 {
4247 14 music_pause();
4248 14 pause_all_sfx();
4249 14 }
4250 14 enter_sys_pal();
4251 14 clear_keybuf();
4252
4253
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if (replay_is_active() && replay_get_version() <= 9)
4254 14 replay_poll();
4255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4256 14 replay_peek_quit();
4257
4258
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4259 switch(type)
4260 {
4261 case qQUIT:
4262 onQuit();
4263 break;
4264
4265 case qRESET:
4266 onReset();
4267 break;
4268
4269 case qEXIT:
4270 onExit();
4271 break;
4272 }
4273
4274
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4275 {
4276 14 kill_sfx();
4277 14 music_stop();
4278 14 exit_sys_pal();
4279 14 update_hw_screen();
4280 14 }
4281 else
4282 {
4283 exit_sys_pal();
4284 if(!from_menu)
4285 {
4286 music_resume();
4287 resume_all_sfx();
4288 }
4289 }
4290
4291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4292 14 eat_buttons();
4293
4294 14 zc_readrawkey(KEY_ESC);
4295
4296 14 zc_readrawkey(KEY_ENTER);
4297 14 }
4298
4299 //----------------------------------------------------------------
4300
4301 int32_t onNoWalls()
4302 {
4303 cheats_enqueue(Cheat::Walls);
4304 return D_O_K;
4305 }
4306
4307 int32_t onIgnoreSideview()
4308 {
4309 cheats_enqueue(Cheat::IgnoreSideView);
4310 return D_O_K;
4311 }
4312
4313 6510614 int32_t input_idle(bool checkmouse)
4314 {
4315 static int32_t mx, my, mz, mb;
4316
4317
4/6
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621032 times.
✓ Branch 3 taken 4889582 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1621032 times.
8131646 if(keypressed() || zc_key_pressed() ||
4318
4/8
✓ Branch 0 taken 1621032 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621032 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1621032 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1621032 times.
✗ Branch 7 not taken.
1621032 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4319 {
4320 4889582 idle_count = 0;
4321
4322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4889582 times.
4889582 if(active_count < MAX_ACTIVE)
4323 {
4324 4889582 ++active_count;
4325 4889582 }
4326 4889582 }
4327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1621032 times.
1621032 else if(idle_count < MAX_IDLE)
4328 {
4329 1621032 ++idle_count;
4330 1621032 active_count = 0;
4331 1621032 }
4332
4333 6510614 mx = mouse_x;
4334 6510614 my = mouse_y;
4335 6510614 mz = mouse_z;
4336 6510614 mb = mouse_b;
4337
4338 6510614 return idle_count;
4339 }
4340
4341 int32_t onGoFast()
4342 {
4343 cheats_enqueue(Cheat::Fast);
4344 return D_O_K;
4345 }
4346
4347 int32_t onKillCheat()
4348 {
4349 cheats_enqueue(Cheat::Kill);
4350 return D_O_K;
4351 }
4352
4353 int32_t onSecretsCheat()
4354 {
4355 cheats_enqueue(Cheat::TrigSecrets);
4356 return D_O_K;
4357 }
4358 int32_t onSecretsCheatPerm()
4359 {
4360 cheats_enqueue(Cheat::TrigSecretsPerm);
4361 return D_O_K;
4362 }
4363
4364 int32_t onShowLayer0()
4365 {
4366 show_layer_0 = !show_layer_0;
4367 return D_O_K;
4368 }
4369 int32_t onShowLayer1()
4370 {
4371 show_layer_1 = !show_layer_1;
4372 return D_O_K;
4373 }
4374 int32_t onShowLayer2()
4375 {
4376 show_layer_2 = !show_layer_2;
4377 return D_O_K;
4378 }
4379 int32_t onShowLayer3()
4380 {
4381 show_layer_3 = !show_layer_3;
4382 return D_O_K;
4383 }
4384 int32_t onShowLayer4()
4385 {
4386 show_layer_4 = !show_layer_4;
4387 return D_O_K;
4388 }
4389 int32_t onShowLayer5()
4390 {
4391 show_layer_5 = !show_layer_5;
4392 return D_O_K;
4393 }
4394 int32_t onShowLayer6()
4395 {
4396 show_layer_6 = !show_layer_6;
4397 return D_O_K;
4398 }
4399 int32_t onShowLayerO()
4400 {
4401 show_layer_over=!show_layer_over;
4402 return D_O_K;
4403 }
4404 int32_t onShowLayerP()
4405 {
4406 show_layer_push=!show_layer_push;
4407 return D_O_K;
4408 }
4409 int32_t onShowLayerS()
4410 {
4411 show_sprites=!show_sprites;
4412 return D_O_K;
4413 }
4414 int32_t onShowLayerF()
4415 {
4416 show_ffcs=!show_ffcs;
4417 return D_O_K;
4418 }
4419 int32_t onShowLayerW()
4420 {
4421 show_walkflags=!show_walkflags;
4422 if(show_walkflags)
4423 show_effectflags = false;
4424 return D_O_K;
4425 }
4426 int32_t onShowLayerE()
4427 {
4428 show_effectflags=!show_effectflags;
4429 if(show_effectflags)
4430 show_walkflags = false;
4431 return D_O_K;
4432 }
4433 int32_t onShowFFScripts()
4434 {
4435 show_ff_scripts=!show_ff_scripts;
4436 return D_O_K;
4437 }
4438 int32_t onShowHitboxes()
4439 {
4440 show_hitboxes=!show_hitboxes;
4441 return D_O_K;
4442 }
4443 int32_t onShowInfoOpacity()
4444 {
4445 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4446 zc_set_config("zc","debug_info_opacity",info_opacity);
4447 return D_O_K;
4448 }
4449
4450 int32_t onLightSwitch()
4451 {
4452 cheats_enqueue(Cheat::Light);
4453 return D_O_K;
4454 }
4455
4456 int32_t onGoTo();
4457 int32_t onGoToComplete();
4458
4459 6510614 void syskeys()
4460 {
4461 6510614 update_system_keys();
4462
4463 int32_t oldtitle_version;
4464
4465
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(close_button_quit)
4466 {
4467 close_button_quit=false;
4468 f_Quit(qEXIT);
4469 }
4470
4471 6510614 poll_joystick();
4472
4473
2/10
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6510614 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
6510614 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4474 {
4475 oldtitle_version=title_version;
4476 System();
4477 }
4478
4479 6510614 mouse_down=gui_mouse_b();
4480
4481
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F1))
4482 {
4483 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4484 {
4485 halt=!halt;
4486 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4487 }
4488 else
4489 {
4490 Throttlefps=!Throttlefps;
4491 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4492 logic_counter=0;
4493 }
4494 }
4495
4496 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4497 /*
4498 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4499 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4500 */
4501
4502
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F2))
4503 {
4504 ShowFPS=!ShowFPS;
4505 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4506 }
4507
4508
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4509
4510
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(zc_read_system_key(KEY_F4) && Playing)
4511 {
4512 Paused=true;
4513 Advance=true;
4514 }
4515
4516
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F6)) onTryQuit();
4517
4518 #ifndef ALLEGRO_MACOSX
4519
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4520
4521
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4522 #else
4523 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4524
4525 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4526 #endif
4527
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6510614 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4528
4529
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if (zc_read_system_key(KEY_F12))
4530 {
4531 onSnapshot();
4532 }
4533
4534
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(debug_enabled && zc_read_system_key(KEY_TAB))
4535 set_debug(!get_debug());
4536
4537
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(CheatModifierKeys())
4538 {
4539 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4540 {
4541 if(!bindable_cheat(c))
4542 continue;
4543 if(get_debug() || cheat >= cheat_lvl(c))
4544 {
4545 if(checkcheat(c))
4546 cheats_hit_bind(c);
4547 }
4548 }
4549 }
4550
4551
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(volkeys)
4552 {
4553 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4554
4555 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4556
4557 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4558
4559 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4560 }
4561
4562
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6510614 if(!get_debug() || !SystemKeys || replay_is_replaying())
4563 6510614 goto bottom;
4564
4565 if(zc_readkey(KEY_D))
4566 {
4567 details = !details;
4568 rectfill(screen,0,0,319,7,BLACK);
4569 rectfill(screen,0,8,31,239,BLACK);
4570 rectfill(screen,288,8,319,239,BLACK);
4571 rectfill(screen,32,232,287,239,BLACK);
4572 }
4573
4574 if(zc_readkey(KEY_P)) Paused=!Paused;
4575
4576 //if(zc_readkey(KEY_P)) centerHero();
4577 if(zc_readkey(KEY_A))
4578 {
4579 Paused=true;
4580 Advance=true;
4581 }
4582
4583 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4584 #ifndef ALLEGRO_MACOSX
4585 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4586
4587 if(zc_readkey(KEY_F7))
4588 {
4589 Matrix(ss_speed, ss_density, 0);
4590 game_pal();
4591 }
4592 #else
4593 // The reason these are different on Mac in the first place is that
4594 // the OS doesn't let us use F9 and F10...
4595 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4596
4597 if(zc_readkey(KEY_F9))
4598 {
4599 Matrix(ss_speed, ss_density, 0);
4600 game_pal();
4601 }
4602 #endif
4603 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4604 {
4605 //change containers
4606 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4607 {
4608 //magic containers
4609 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4610 {
4611 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4612 }
4613 else
4614 {
4615 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4616 }
4617 }
4618 else
4619 {
4620 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4621 {
4622 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4623 }
4624 else
4625 {
4626 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4627 }
4628 }
4629 }
4630
4631 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4632 {
4633 //change containers
4634 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4635 {
4636 //magic containers
4637 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4638 {
4639 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4640 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4641 //heart containers
4642 }
4643 else
4644 {
4645 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4646 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4647 }
4648 }
4649 else
4650 {
4651 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4652 {
4653 game->set_magic(zc_max(game->get_magic()-1,0));
4654 }
4655 else
4656 {
4657 game->set_life(zc_max(game->get_life()-1,0));
4658 }
4659 }
4660 }
4661
4662 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4663
4664 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4665
4666 verifyBothWeapons();
4667
4668 bottom:
4669
4670
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(input_idle(true) > after_time())
4671 {
4672 Matrix(ss_speed, ss_density, 0);
4673 game_pal();
4674 }
4675 6510614 }
4676
4677 330136 void checkQuitKeys()
4678 {
4679 #ifndef ALLEGRO_MACOSX
4680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F9]) f_Quit(qRESET);
4681
4682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F10]) f_Quit(qEXIT);
4683 #else
4684 if(key[KEY_F7]) f_Quit(qRESET);
4685
4686 if(key[KEY_F8]) f_Quit(qEXIT);
4687 #endif
4688 330136 }
4689
4690 6510614 bool CheatModifierKeys()
4691 {
4692 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4693 // to trigger cheats.
4694
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if (replay_is_replaying())
4695 6510614 return false;
4696
4697 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4698 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4699 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4700 {
4701 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4702 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4703 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4704 {
4705 return true;
4706 }
4707 }
4708 return false;
4709 6510614 }
4710
4711 //99:05:54, for some reason?
4712 #define OLDMAXTIME 21405240
4713 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4714 #define MAXTIME 1944000000
4715
4716 6510665 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4717 {
4718
2/2
✓ Branch 0 taken 6242564 times.
✓ Branch 1 taken 268101 times.
6510665 if(zcmusic!=NULL)
4719 {
4720 268101 zcmusic_poll();
4721 268101 }
4722
4723 6510665 updatescr(allowwavy);
4724
4725 6510665 Advance=false;
4726
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6510665 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6510665 times.
6510665 while(Paused && !Advance && !Quit)
4727 {
4728 // have to call this, otherwise we'll get an infinite loop
4729 syskeys();
4730 if(allowF6Script)
4731 {
4732 FFCore.runF6Engine();
4733 }
4734 throttleFPS();
4735
4736 #ifdef _WIN32
4737
4738 if(use_dwm_flush)
4739 {
4740 do_DwmFlush();
4741 }
4742
4743 #endif
4744
4745 // to keep music playing
4746 if(zcmusic!=NULL)
4747 {
4748 zcmusic_poll();
4749 }
4750
4751 update_hw_screen();
4752 }
4753
4754
2/2
✓ Branch 0 taken 6510624 times.
✓ Branch 1 taken 41 times.
6510665 if(Quit)
4755 41 return;
4756
4757
3/4
✓ Branch 0 taken 6428635 times.
✓ Branch 1 taken 81989 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6428635 times.
6510624 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4758 6428635 game->change_time(1);
4759
4760
2/4
✓ Branch 0 taken 6510624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6510624 times.
6510624 if (!replay_is_active() || replay_get_version() >= 11)
4761 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4762 down_control_states[i] = raw_control_state[i];
4763
4764
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510622 times.
6510624 if (replay_is_active())
4765 {
4766
2/2
✓ Branch 0 taken 1270461 times.
✓ Branch 1 taken 5240161 times.
6510622 if (replay_get_version() >= 3)
4767 5240161 replay_poll();
4768
4769
5/6
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3089962 times.
✓ Branch 3 taken 3420652 times.
✓ Branch 4 taken 100535 times.
✓ Branch 5 taken 2989427 times.
6510622 if (replay_get_version() >= 11 || (replay_get_version() >= 6 && replay_get_version() < 8))
4770 100535 replay_peek_input();
4771 6510614 }
4772
4773 6510624 load_control_called_this_frame = false;
4774
4775 6510624 poll_keyboard();
4776 6510624 update_keys();
4777
4778 6510624 ++frame;
4779
4780
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510614 times.
6510624 if (replay_is_replaying())
4781 6510614 replay_do_cheats();
4782 6510624 syskeys();
4783
4784 // The mouse variables can change from the mouse thread at anytime during a frame,
4785 // so save the result at the start so that replaying is consistent.
4786 6510624 script_mouse_x = gui_mouse_x();
4787 6510624 script_mouse_y = gui_mouse_y();
4788 6510624 script_mouse_z = mouse_z;
4789 6510624 script_mouse_b = mouse_b;
4790
4791 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4792 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4793 // approach here means it doesn't matter which call adds the cheat.
4794 6510624 cheats_execute_queued();
4795
4796
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510614 times.
6510624 if (replay_is_replaying())
4797 6510614 replay_peek_quit();
4798
2/2
✓ Branch 0 taken 6510610 times.
✓ Branch 1 taken 14 times.
6510624 if (GameFlags & GAMEFLAG_TRYQUIT)
4799 14 replay_step_quit(0);
4800
2/2
✓ Branch 0 taken 1835 times.
✓ Branch 1 taken 6508789 times.
6510624 if(allowF6Script)
4801 6508789 FFCore.runF6Engine();
4802
2/2
✓ Branch 0 taken 6510449 times.
✓ Branch 1 taken 175 times.
6510624 if (Quit)
4803 175 replay_step_quit(Quit);
4804 // Someday... maybe install a Turbo button here?
4805 6510624 throttleFPS();
4806
4807 #ifdef _WIN32
4808
4809 if(use_dwm_flush)
4810 {
4811 do_DwmFlush();
4812 }
4813
4814 #endif
4815
4816 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4817
2/2
✓ Branch 0 taken 29901 times.
✓ Branch 1 taken 6480723 times.
6510624 if(sfxcleanup)
4818 6480723 sfx_cleanup();
4819 6510665 }
4820
4821 59 void zapout()
4822 {
4823 59 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4824 59 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4825
4826 59 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4827 59 script_drawing_commands.Clear();
4828
4829 // zap out
4830
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1416 times.
1475 for(int32_t i=1; i<=24; i++)
4831 {
4832 1416 draw_fuzzy(i);
4833 1416 advanceframe(true);
4834
4835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1416 times.
1416 if(Quit)
4836 {
4837 break;
4838 }
4839 1416 }
4840 59 }
4841
4842 59 void zapin()
4843 {
4844 59 FFCore.warpScriptCheck();
4845 59 draw_screen(tmpscr);
4846 59 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4847 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4848 59 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4849
4850 // zap out
4851 59 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4852
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1416 times.
1475 for(int32_t i=24; i>=1; i--)
4853 {
4854 1416 draw_fuzzy(i);
4855 1416 advanceframe(true);
4856
4857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1416 times.
1416 if(Quit)
4858 {
4859 break;
4860 }
4861 1416 }
4862 59 }
4863
4864
4865 23 void wavyout(bool showhero)
4866 {
4867 23 draw_screen(tmpscr, showhero);
4868 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4869
4870 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4871 23 clear_to_color(wavebuf,0);
4872 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4873
4874 static PALETTE wavepal;
4875
4876 int32_t ofs;
4877 23 int32_t amplitude=8;
4878
4879 23 int32_t wavelength=4;
4880 23 double palpos=0, palstep=4, palstop=126;
4881
4882 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4883
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4884 {
4885
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4886 {
4887 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4888 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4889 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4890 247296 }
4891
4892 966 palpos+=palstep;
4893
4894
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4895 {
4896 966 hw_palette = &wavepal;
4897 966 update_hw_pal = true;
4898 966 }
4899 else
4900 {
4901 hw_palette = &RAMpal;
4902 update_hw_pal = true;
4903 }
4904
4905
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4906 {
4907
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4908 {
4909 41545728 ofs=0;
4910
4911
4/4
✓ Branch 0 taken 20278272 times.
✓ Branch 1 taken 21267456 times.
✓ Branch 2 taken 10139136 times.
✓ Branch 3 taken 10139136 times.
41545728 if((j<i)&&(j&1))
4912 {
4913 10139136 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4914 10139136 }
4915
4916 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4917 41545728 }
4918 162288 }
4919
4920 966 advanceframe(true);
4921
4922 // animate_combos();
4923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4924 break;
4925 966 }
4926
4927 23 destroy_bitmap(wavebuf);
4928 23 }
4929
4930 23 void wavyin()
4931 {
4932 23 draw_screen(tmpscr);
4933 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4934
4935 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4936 23 clear_to_color(wavebuf,0);
4937 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4938
4939 static PALETTE wavepal;
4940
4941 //Breaks dark rooms.
4942 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4943 /*
4944 loadfullpal();
4945 loadlvlpal(DMaps[currdmap].color);
4946 ringcolor(false);
4947 */
4948 23 refreshpal=false;
4949 int32_t ofs;
4950 23 int32_t amplitude=8;
4951 23 int32_t wavelength=4;
4952 23 double palpos=168, palstep=4, palstop=126;
4953
4954 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4955
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4956 {
4957
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4958 {
4959 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4960 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4961 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4962 247296 }
4963
4964 966 palpos-=palstep;
4965
4966
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4967 {
4968 966 hw_palette = &wavepal;
4969 966 update_hw_pal = true;
4970 966 }
4971 else
4972 {
4973 hw_palette = &RAMpal;
4974 update_hw_pal = true;
4975 }
4976
4977
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4978 {
4979
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4980 {
4981 41545728 ofs=0;
4982
4983
4/4
✓ Branch 0 taken 21020160 times.
✓ Branch 1 taken 20525568 times.
✓ Branch 2 taken 10633728 times.
✓ Branch 3 taken 10386432 times.
41545728 if((j<(167-i))&&(j&1))
4984 {
4985 10386432 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4986 10386432 }
4987
4988 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4989 41545728 }
4990 162288 }
4991
4992 966 advanceframe(true);
4993 // animate_combos();
4994
4995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4996 break;
4997 966 }
4998
4999 23 destroy_bitmap(wavebuf);
5000 23 }
5001
5002 1619 void blackscr(int32_t fcnt,bool showsubscr)
5003 {
5004 1619 reset_pal_cycling();
5005 1619 script_drawing_commands.Clear();
5006
5007 1619 FFCore.warpScriptCheck();
5008 1619 bool showtime = game->should_show_time();
5009
2/2
✓ Branch 0 taken 1619 times.
✓ Branch 1 taken 48500 times.
50119 while(fcnt>0)
5010 {
5011 48500 clear_bitmap(framebuf);
5012
5013
2/2
✓ Branch 0 taken 13500 times.
✓ Branch 1 taken 35000 times.
48500 if(showsubscr)
5014 {
5015 35000 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5016
3/4
✓ Branch 0 taken 35000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 34250 times.
35000 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5017 {
5018 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5019 750 }
5020 35000 }
5021
5022 48500 advanceframe(true);
5023
5024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48500 times.
48500 if(Quit)
5025 break;
5026
5027 48500 --fcnt;
5028 }
5029 1619 }
5030
5031 563 void openscreen(int32_t shape)
5032 {
5033 563 reset_pal_cycling();
5034 563 black_opening_count=0;
5035
5036
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 465 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
563 if(COOLSCROLL || shape>-1)
5037 {
5038 465 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5039 465 return;
5040 }
5041 else
5042 {
5043 98 Hero.setDontDraw(true);
5044 98 show_subscreen_dmap_dots=false;
5045 98 show_subscreen_numbers=false;
5046 // show_subscreen_items=false;
5047 98 show_subscreen_life=false;
5048 }
5049
5050 98 int32_t x=128;
5051
5052 98 FFCore.warpScriptCheck();
5053
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7840 times.
7938 for(int32_t i=0; i<80; i++)
5054 {
5055 7840 draw_screen(tmpscr);
5056 //? draw_screen already draws the subscreen -DD
5057 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5058 7840 x=128-(((i*128/80)/8)*8);
5059
5060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(x>0)
5061 {
5062 7840 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5063 7840 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5064 7840 }
5065
5066 7840 advanceframe(true);
5067
5068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(Quit)
5069 {
5070 break;
5071 }
5072 7840 }
5073
5074 98 Hero.setDontDraw(false);
5075 98 show_subscreen_items=true;
5076 98 show_subscreen_dmap_dots=true;
5077 563 }
5078
5079 void closescreen(int32_t shape)
5080 {
5081 reset_pal_cycling();
5082 black_opening_count=0;
5083
5084 if(COOLSCROLL || shape>-1)
5085 {
5086 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5087 return;
5088 }
5089 else
5090 {
5091 Hero.setDontDraw(true);
5092 show_subscreen_dmap_dots=false;
5093 show_subscreen_numbers=false;
5094 // show_subscreen_items=false;
5095 show_subscreen_life=false;
5096 }
5097
5098 int32_t x=128;
5099
5100 FFCore.warpScriptCheck();
5101 for(int32_t i=79; i>=0; --i)
5102 {
5103 draw_screen(tmpscr);
5104 //? draw_screen already draws the subscreen -DD
5105 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5106 x=128-(((i*128/80)/8)*8);
5107
5108 if(x>0)
5109 {
5110 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5111 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5112 }
5113
5114 advanceframe(true);
5115
5116 if(Quit)
5117 {
5118 break;
5119 }
5120 }
5121
5122 Hero.setDontDraw(false);
5123 show_subscreen_items=true;
5124 show_subscreen_dmap_dots=true;
5125 }
5126
5127 122 int32_t TriforceCount()
5128 {
5129 122 int32_t c=0;
5130
5131
2/2
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 122 times.
1098 for(int32_t i=1; i<=8; i++)
5132
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 650 times.
1626 if(game->lvlitems[i]&liTRIFORCE)
5133 650 ++c;
5134
5135 122 return c;
5136 }
5137
5138 int32_t onCustomGame()
5139 {
5140 int32_t file = getsaveslot();
5141
5142 if(file < 0)
5143 return D_O_K;
5144
5145 bool ret = (custom_game(file)!=0);
5146 return ret ? D_CLOSE : D_O_K;
5147 }
5148
5149 int32_t onContinue()
5150 {
5151 return D_CLOSE;
5152 }
5153
5154 int32_t onEsc() // Unused?? -L
5155 {
5156 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5157 }
5158
5159 int32_t onVsync()
5160 {
5161 Throttlefps = !Throttlefps;
5162 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5163 return D_O_K;
5164 }
5165
5166 int32_t onWinPosSave()
5167 {
5168 SaveWinPos = !SaveWinPos;
5169 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5170 return D_O_K;
5171 }
5172 int32_t onIntegerScaling()
5173 {
5174 scaleForceInteger = !scaleForceInteger;
5175 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5176 return D_O_K;
5177 }
5178
5179 int32_t onClickToFreeze()
5180 {
5181 ClickToFreeze = !ClickToFreeze;
5182 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5183 return D_O_K;
5184 }
5185
5186 int32_t OnSaveZCConfig()
5187 {
5188 if(jwin_alert3(
5189 "Save Configuration",
5190 "Are you sure that you wish to save your present configuration settings?",
5191 "This will overwrite your prior settings!",
5192 NULL,
5193 "&Yes",
5194 "&No",
5195 NULL,
5196 'y',
5197 'n',
5198 0,
5199 get_zc_font(font_lfont)) == 1)
5200 {
5201 save_game_configs();
5202 return D_O_K;
5203 }
5204 else return D_O_K;
5205 }
5206
5207 int32_t OnnClearQuestDir()
5208 {
5209 if(jwin_alert3(
5210 "Clear Current Directory Cache",
5211 "Are you sure that you wish to clear the current cached directory?",
5212 "This will default the current directory to the ROOT for this instance of ZC Player!",
5213 NULL,
5214 "&Yes",
5215 "&No",
5216 NULL,
5217 'y',
5218 'n',
5219 0,
5220 get_zc_font(font_lfont)) == 1)
5221 {
5222 zc_set_config("zeldadx","win_qst_dir","");
5223 flush_config_file();
5224 strcpy(qstdir,"");
5225 #ifdef __EMSCRIPTEN__
5226 em_sync_fs();
5227 #endif
5228 return D_O_K;
5229 }
5230 else return D_O_K;
5231 }
5232
5233
5234 int32_t onConsoleZASM()
5235 {
5236 if ( !zasm_debugger )
5237 {
5238 AlertDialog("WARNING: ZASM Debugger",
5239 "Enabling this will open the ZASM Debugger Console"
5240 "\nThis will likely grind ZC to a halt with lag."
5241 "\nTo make any use of this, it is suggested that you read"
5242 "\nthe documentation for 'void Breakpoint(char[] string);'"
5243 " in 'ZScript_Additions.txt'"
5244 "\nThis is not recommended for normal users,"
5245 " and is only intended for ZC developers,"
5246 "\nor quest developers coding directly in ZASM"
5247 "\nAre you sure that you wish to open the ZASM Debugger?",
5248 [&](bool ret,bool)
5249 {
5250 if(ret)
5251 {
5252 FFCore.ZASMPrint(true);
5253 }
5254 }).show();
5255 return D_O_K;
5256 }
5257 else
5258 {
5259 FFCore.ZASMPrint(false);
5260 return D_O_K;
5261 }
5262 }
5263
5264
5265 int32_t onConsoleZScript()
5266 {
5267 if ( !zscript_debugger )
5268 {
5269 AlertDialog("ZScript Debugger",
5270 "Enabling this will open the ZScript Debugger Console"
5271 "\nThis will display any messages logged by scripts,"
5272 " including script errors."
5273 "\nAre you sure that you wish to open the ZScript Debugger?",
5274 [&](bool ret,bool)
5275 {
5276 if(ret)
5277 {
5278 FFCore.ZScriptConsole(true);
5279 }
5280 }).show();
5281 return D_O_K;
5282 }
5283 else
5284 {
5285 FFCore.ZScriptConsole(false);
5286 return D_O_K;
5287 }
5288 }
5289
5290 int32_t onClrConsoleOnReload()
5291 {
5292 clearConsoleOnReload = !clearConsoleOnReload;
5293 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5294 return D_O_K;
5295 }
5296 int32_t onClrConsoleOnLoad()
5297 {
5298 clearConsoleOnLoad = !clearConsoleOnLoad;
5299 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5300 return D_O_K;
5301 }
5302
5303
5304 int32_t onFrameSkip()
5305 {
5306 FrameSkip = !FrameSkip;
5307 return D_O_K;
5308 }
5309
5310 int32_t onSaveDragResize()
5311 {
5312 SaveDragResize = !SaveDragResize;
5313 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5314 return D_O_K;
5315 }
5316
5317 int32_t onDragAspect()
5318 {
5319 DragAspect = !DragAspect;
5320 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5321 return D_O_K;
5322 }
5323
5324 int32_t onTransLayers()
5325 {
5326 TransLayers = !TransLayers;
5327 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5328 return D_O_K;
5329 }
5330
5331 int32_t onNESquit()
5332 {
5333 NESquit = !NESquit;
5334 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5335 return D_O_K;
5336 }
5337
5338 int32_t onVolKeys()
5339 {
5340 volkeys = !volkeys;
5341 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5342 return D_O_K;
5343 }
5344
5345 int32_t onShowFPS()
5346 {
5347 ShowFPS = !ShowFPS;
5348 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5349 return D_O_K;
5350 }
5351
5352 768252452 bool is_Fkey(int32_t k)
5353 {
5354
2/2
✓ Branch 0 taken 78127368 times.
✓ Branch 1 taken 690125084 times.
768252452 switch(k)
5355 {
5356 case KEY_F1:
5357 case KEY_F2:
5358 case KEY_F3:
5359 case KEY_F4:
5360 case KEY_F5:
5361 case KEY_F6:
5362 case KEY_F7:
5363 case KEY_F8:
5364 case KEY_F9:
5365 case KEY_F10:
5366 case KEY_F11:
5367 case KEY_F12:
5368 78127368 return true;
5369 }
5370
5371 690125084 return false;
5372 768252452 }
5373
5374 void kb_getkey(DIALOG *d);
5375
5376 //Used by all keyboard key settings dialogues.
5377 void kb_clearjoystick(DIALOG *d)
5378 {
5379 d->flags|=D_SELECTED;
5380
5381 jwin_button_proc(MSG_DRAW,d,0);
5382 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5383 // text_mode(vc(11));
5384 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5385 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5386
5387 update_hw_screen(true);
5388
5389 clear_keybuf();
5390 int32_t k = next_press_key();
5391 clear_keybuf();
5392
5393 //shnarf
5394 //47=f1
5395 //59=esc
5396 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5397 // *((int32_t*)d->dp3) = k;
5398 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5399
5400
5401 d->flags&=~D_SELECTED;
5402 }
5403
5404 //Clears key to 0.
5405 //Used by all keyboard key settings dialogues.
5406 void kb_clearkey(DIALOG *d);
5407
5408 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5409 {
5410 switch(msg)
5411 {
5412 case MSG_KEY:
5413 case MSG_CLICK:
5414
5415 kb_clearjoystick(d);
5416
5417 while(gui_mouse_b())
5418 {
5419 clear_keybuf();
5420 rest(1);
5421 }
5422
5423 return D_REDRAW;
5424 }
5425
5426 return jwin_button_proc(msg,d,c);
5427 }
5428
5429 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5430 //Only used in keyboard settings dialogues to clear keys.
5431 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5432
5433 void j_getbtn(DIALOG *d)
5434 {
5435 d->flags|=D_SELECTED;
5436 jwin_button_proc(MSG_DRAW,d,0);
5437 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5438 // text_mode(vc(11));
5439 int32_t y = gui_bmp->h/2 - 12;
5440 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5441 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5442 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5443
5444 update_hw_screen(true);
5445
5446 int32_t b = next_press_btn();
5447
5448 if(b>=0)
5449 *((int32_t*)d->dp3) = b;
5450
5451 d->flags&=~D_SELECTED;
5452
5453 if (player)
5454 player->joy_on = TRUE;
5455 }
5456
5457 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5458 {
5459 switch(msg)
5460 {
5461 case MSG_KEY:
5462 case MSG_CLICK:
5463
5464 j_getbtn(d);
5465
5466 while(gui_mouse_b()) {
5467 rest(1);
5468 clear_keybuf();
5469 }
5470
5471 return D_REDRAW;
5472 }
5473
5474 return jwin_button_proc(msg,d,c);
5475 }
5476
5477 //shnarf
5478 extern const char *key_str[];
5479 std::string get_keystr(int key);
5480
5481 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5482 //extern int32_t zcmusic_bufsz;
5483
5484 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5485 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5486
5487 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5488 {
5489 //these are here to bypass compiler warnings about unused arguments
5490 c=c;
5491
5492 if(msg==MSG_DRAW)
5493 {
5494 switch(d->w)
5495 {
5496 case 0:
5497 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5498 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5499 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5500 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5501 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5502 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5503 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5504 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5505 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5506 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5507 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5508 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5509 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5510 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5511 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5512 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5513 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5514 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5515 break;
5516
5517 case 1:
5518 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5519 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5520 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5521 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5522 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5523 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5524 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5525 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5526 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5527 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5528 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5529 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5530 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5531 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5532 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5533 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5534 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5535 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5536 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5537 break;
5538
5539 case 2:
5540 sprintf(str_a," %3d",midi_volume);
5541 sprintf(str_b," %3d",digi_volume);
5542 sprintf(str_l," %3d",emusic_volume);
5543 sprintf(str_m," %3dKB",zcmusic_bufsz);
5544 sprintf(str_r," %3d",sfx_volume);
5545 strcpy(str_s,pan_str[pan_style]);
5546 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5547 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5548 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5549 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5550 break;
5551 }
5552 }
5553
5554 return D_O_K;
5555 }
5556
5557 int32_t set_vol(void *dp3, int32_t d2)
5558 {
5559 switch(((int32_t*)dp3)[0])
5560 {
5561 case 0:
5562 midi_volume = zc_min(d2<<3,255);
5563 break;
5564
5565 case 1:
5566 digi_volume = zc_min(d2<<3,255);
5567 break;
5568
5569 case 2:
5570 emusic_volume = zc_min(d2<<3,255);
5571 break;
5572
5573 case 3:
5574 sfx_volume = zc_min(d2<<3,255);
5575 break;
5576 }
5577
5578 // text_mode(vc(11));
5579 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5580 return D_O_K;
5581 }
5582
5583 int32_t set_pan(void *dp3, int32_t d2)
5584 {
5585 pan_style = vbound(d2,0,3);
5586 // text_mode(vc(11));
5587 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5588 return D_O_K;
5589 }
5590
5591 int32_t set_buf(void *dp3, int32_t d2)
5592 {
5593 // text_mode(vc(11));
5594 zcmusic_bufsz = d2 + 1;
5595 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5596 return D_O_K;
5597 }
5598
5599 static int32_t gamepad_btn_list[] =
5600 {
5601 6,
5602 7,8,9,10,11,12,13,14,15,16,17,
5603 18,19,20,21,22,23,24,25,26,27,28,
5604 29,30,31,32,33,34,35,36,37,38,39,
5605 -1
5606 };
5607
5608 static int32_t gamepad_dirs_list[] =
5609 {
5610 40,41,42,43,
5611 44,45,46,47,
5612 48,49,50,51,
5613 52,53,54,55,
5614 56,
5615 -1
5616 };
5617
5618 static TABPANEL gamepad_tabs[] =
5619 {
5620 // (text)
5621 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5622 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5623 { NULL, 0, NULL, 0, NULL }
5624 };
5625
5626 static DIALOG gamepad_dlg[] =
5627 {
5628 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5629 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5630 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5631 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5632 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5633 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5634 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5635 // 6
5636 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5637 // 7
5638 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5639 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5640 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5641 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5642 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5643 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5644 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5645 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5646 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5647 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5648 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5649 // 18
5650 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5651 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5652 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5653 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5654 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5655 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5656 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5657 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5658 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5659 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5660 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5661 // 29
5662 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5663 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5664 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5665 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5666 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5667 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5668 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5669 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5670 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5671 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5672 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5673 // 40
5674 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5675 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5676 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5677 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5678 // 44
5679 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5680 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5681 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5682 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5683 // 48
5684 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5685 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5686 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5687 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5688 // 52
5689 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5690 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5691 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5692 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5693 // 56
5694 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5695 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5696 };
5697
5698 static int32_t keyboard_keys_list[] =
5699 {
5700 6,7,8,9,10,
5701 11,12,13,14,15,16,17,18,19,20,
5702 21,22,23,24,25,26,27,28,29,30,
5703 31,32,33,34,35,36,37,38,39,40,
5704 -1
5705 };
5706
5707 static int32_t keyboard_dirs_list[] =
5708 {
5709 41,42,43,44,
5710 45,46,47,48,
5711 49,50,51,52,
5712 53,54,55,56,
5713 -1
5714 };
5715
5716 static int32_t keyboard_mods_list[] =
5717 {
5718 57,58,59,60,
5719 61,62,63,64,
5720 65,66,67,68,
5721 69,70,71,72,
5722 -1
5723 };
5724
5725 static TABPANEL keyboard_control_tabs[] =
5726 {
5727 // (text)
5728 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5729 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5730 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5731 { NULL, 0, NULL, 0, NULL }
5732 };
5733
5734 static DIALOG keyboard_control_dlg[] =
5735 {
5736 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5737 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5738 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5739 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5740 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5741 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5742 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5743 // Keys
5744 // 6
5745 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5746 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5747 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5748 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5749 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5750 // 11
5751 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5752 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5753 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5754 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5755 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5756 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5757 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5758 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5759 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5760 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5761 // 21
5762 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5763 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5764 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5765 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5766 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5767 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5768 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5769 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5770 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5771 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5772 // 31
5773 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5774 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5775 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5776 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5777 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5778 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5779 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5780 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5781 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5782 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5783 // Dirs
5784 // 41
5785 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5786 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5787 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5788 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5789 // 45
5790 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5791 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5792 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5793 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5794 // 49
5795 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5796 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5797 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5798 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5799 // 53
5800 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5801 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5802 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5803 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5804 // Mods
5805 // 57
5806 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5807 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5808 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5809 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5810 // 61
5811 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5812 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5813 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5814 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5815 // 65
5816 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5817 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5818 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5819 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5820 // 69
5821 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5822 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5823 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5824 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5825 // 73
5826 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5827 };
5828
5829 /*
5830 int32_t midi_dp[3] = {0,147,104};
5831 int32_t digi_dp[3] = {1,147,120};
5832 int32_t pan_dp[3] = {0,147,136};
5833 int32_t buf_dp[3] = {0,147,152};
5834 */
5835 int32_t midi_dp[3] = {0,0,0};
5836 int32_t digi_dp[3] = {1,0,0};
5837 int32_t emus_dp[3] = {2,0,0};
5838 int32_t buf_dp[3] = {0,0,0};
5839 int32_t sfx_dp[3] = {3,0,0};
5840 int32_t pan_dp[3] = {0,0,0};
5841
5842 static DIALOG sound_dlg[] =
5843 {
5844 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5845 29 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5846 29 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5847 29 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5848 29 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5849 29 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5850 29 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5851 29 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5852 29 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5853 29 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5854 29 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5855 // 10
5856 29 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5857 29 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5858 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5859 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5860 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5861 29 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5862 29 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5863 29 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5864 29 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5865 29 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5866 //20
5867 29 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5868 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5869 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5870 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5871 29 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5872 29 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5873 29 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5874 29 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5875 29 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5876 29 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5877 //30
5878 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5879 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5880 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5881 29 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5882 };
5883
5884 char zc_builddate[80];
5885 char zc_aboutstr[80];
5886
5887 static DIALOG about_dlg[] =
5888 {
5889 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5890 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5891 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5892 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5893 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5894 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5895 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5896 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5897 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5898 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5899 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5900 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5901 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5902 };
5903
5904
5905 static DIALOG quest_dlg[] =
5906 {
5907 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5908 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5909 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5910 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5911 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5912 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5913 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5914 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5915 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5916 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5917 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5918 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5919 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5920 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5921 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5922 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5923 };
5924
5925 static DIALOG triforce_dlg[] =
5926 {
5927 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5928 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5929 // 1
5930 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5931 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5932 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5933 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5934 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5935 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5936 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5937 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5938 // 9
5939 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5940 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5941 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5942 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5943 };
5944
5945 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5946 {
5947 go();
5948 int32_t ret=0;
5949 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5950 comeback();
5951 return ret != 0;
5952 }
5953
5954
5955 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5956 {
5957 if(def!=modulepath)
5958 strcpy(modulepath,def);
5959
5960 if(!usefilename)
5961 {
5962 int32_t i=(int32_t)strlen(modulepath);
5963
5964 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5965 modulepath[i--]=0;
5966 }
5967
5968 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5969 int32_t ret=0;
5970 int32_t sel=0;
5971
5972 if(list==NULL)
5973 {
5974 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
5975 }
5976 else
5977 {
5978 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
5979 }
5980
5981 return ret!=0;
5982 }
5983
5984 //The Dialogue that loads a ZMOD Module File
5985 int32_t zc_load_zmod_module_file()
5986 {
5987 if ( Playing )
5988 {
5989 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
5990 return -1;
5991 }
5992 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
5993 return D_CLOSE;
5994
5995 FILE *tempmodule = fopen(modulepath,"r");
5996
5997 if(tempmodule == NULL)
5998 {
5999 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
6000 return -1;
6001 }
6002
6003
6004 //Set the module path:
6005 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6006 strcpy(moduledata.module_name, modulepath);
6007 al_trace("New Module Path is: %s \n", moduledata.module_name);
6008 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6009 zcm.init(true); //Load the module values.
6010 moduledata.refresh_title_screen = 1;
6011 // refresh_select_screen = 1;
6012 build_biic_list();
6013 return D_O_K;
6014 }
6015
6016 static DIALOG module_info_dlg[] =
6017 {
6018 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6019
6020
6021 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6022 //1
6023 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6024 //2
6025 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6026 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6027 //4
6028 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6029 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6030 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6031 //7
6032
6033 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6034 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6035 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6036 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6037 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6038 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6039 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6040 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6041 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6042
6043 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6044 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6045 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6046 };
6047
6048 void about_zcplayer_module(const char *prompt,int32_t initialval)
6049 {
6050
6051 module_info_dlg[0].dp2 = get_zc_font(font_lfont);
6052 if ( moduledata.moduletitle[0] != 0 )
6053 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6054
6055 if ( moduledata.moduleauthor[0] != 0 )
6056 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6057
6058 if ( moduledata.moduleinfo0[0] != 0 )
6059 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6060 if ( moduledata.moduleinfo1[0] != 0 )
6061 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6062 if ( moduledata.moduleinfo2[0] != 0 )
6063 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6064 if ( moduledata.moduleinfo3[0] != 0 )
6065 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6066 if ( moduledata.moduleinfo4[0] != 0 )
6067 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6068
6069 char module_date[255];
6070 memset(module_date, 0, sizeof(module_date));
6071 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6072 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6073
6074
6075
6076 char module_vers[255];
6077 memset(module_vers, 0, sizeof(module_vers));
6078 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6079
6080
6081 //sprintf(tilecount,"%d",1);
6082
6083 char module_build[255];
6084 memset(module_build, 0, sizeof(module_build));
6085 if ( moduledata.modbeta )
6086 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6087 else
6088 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6089
6090 module_info_dlg[12].dp = (char*)module_date;
6091 module_info_dlg[13].dp = (char*)module_vers;
6092 module_info_dlg[14].dp = (char*)module_build;
6093
6094 large_dialog(module_info_dlg);
6095
6096 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6097 jwin_center_dialog(module_info_dlg);
6098
6099
6100 }
6101
6102 int32_t onAbout_ZCP_Module()
6103 {
6104 about_zcplayer_module("About Module (.zmod)", 0);
6105 return D_O_K;
6106 }
6107
6108 //New Modules Menu for 2.55+
6109 static MENU zcmodule_menu[] =
6110 {
6111 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6112 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6113
6114 { NULL, NULL, NULL, 0, NULL }
6115 };
6116
6117 int32_t onToggleRecordingNewSaves()
6118 {
6119 if (zc_get_config("zeldadx", "replay_new_saves", false))
6120 {
6121 zc_set_config("zeldadx", "replay_new_saves", false);
6122 }
6123 else
6124 {
6125 zc_set_config("zeldadx", "replay_new_saves", true);
6126 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6127 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6128 }
6129 return D_O_K;
6130 }
6131
6132 int32_t onToggleSnapshotAllFrames()
6133 {
6134 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6135 return D_O_K;
6136 }
6137
6138 int32_t onStopReplayOrRecord()
6139 {
6140 if (replay_is_replaying())
6141 {
6142 replay_quit();
6143 }
6144 else if (replay_get_mode() == ReplayMode::Record)
6145 {
6146 if (!replay_get_meta_bool("test_mode"))
6147 {
6148 jwin_alert("Recording", "You cannot stop recording a save file.",
6149 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6150 return D_CLOSE;
6151 }
6152
6153 if (jwin_alert("Stop Recording",
6154 "Save replay to disk and stop recording?",
6155 "This will stop the recording.",
6156 NULL,
6157 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6158 return D_CLOSE;
6159
6160 replay_save();
6161 replay_stop();
6162 }
6163 return D_O_K;
6164 }
6165
6166 static int32_t handle_on_load_replay(ReplayMode mode)
6167 {
6168 if (Playing)
6169 {
6170 if (jwin_alert("Replay - Warning!",
6171 "Loading a replay will exit the current game.",
6172 "All unsaved progress will be lost.",
6173 "Do you wish to continue?",
6174 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6175 return D_CLOSE;
6176 }
6177
6178 std::string mode_string = replay_mode_to_string(mode);
6179 mode_string[0] = std::toupper(mode_string[0]);
6180
6181 std::string line_1 = "Select a replay file to play back.";
6182 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6183 std::string line_3 = "You can stop the replay and take over manually any time.";
6184 if (mode == ReplayMode::Update)
6185 {
6186 line_1 = "Select a replay file to update.";
6187 line_2 = "WARNING: be sure to back up the zplay file";
6188 line_3 = "and verify that the updated replay works as expected!";
6189 }
6190
6191 if (jwin_alert(mode_string.c_str(),
6192 line_1.c_str(),
6193 line_2.c_str(),
6194 line_3.c_str(),
6195 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6196 {
6197 char replay_path[2048];
6198 strcpy(replay_path, "replays/");
6199 if (jwin_file_select_ex(
6200 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6201 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6202 return D_CLOSE;
6203
6204 replay_quit();
6205 load_replay_file_deferred(mode, replay_path);
6206 Quit = qRESET;
6207 return D_CLOSE;
6208 }
6209 return D_O_K;
6210 }
6211
6212 int32_t onLoadReplay()
6213 {
6214 return handle_on_load_replay(ReplayMode::Replay);
6215 }
6216
6217 int32_t onLoadReplayAssert()
6218 {
6219 return handle_on_load_replay(ReplayMode::Assert);
6220 }
6221
6222 int32_t onLoadReplayUpdate()
6223 {
6224 return handle_on_load_replay(ReplayMode::Update);
6225 }
6226
6227 int32_t onSaveReplay()
6228 {
6229 if (replay_get_mode() == ReplayMode::Record)
6230 {
6231 if (!replay_get_meta_bool("test_mode"))
6232 {
6233 if (jwin_alert("Save Replay",
6234 "This will save a copy of the replay up to this point.",
6235 "The official replay file will be untouched.",
6236 "Do you wish to continue?",
6237 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6238 return D_CLOSE;
6239
6240 char replay_path[2048];
6241 strcpy(replay_path, replay_get_replay_path().string().c_str());
6242 if (jwin_file_select_ex(
6243 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6244 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6245 return D_CLOSE;
6246
6247 if (fileexists(replay_path))
6248 {
6249 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6250 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6251 return D_CLOSE;
6252 }
6253
6254 replay_save(replay_path);
6255 }
6256 else
6257 {
6258 replay_save();
6259 }
6260 }
6261 return D_O_K;
6262 }
6263
6264 static MENU replay_menu[] =
6265 {
6266 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6267 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6268 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6269 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6270 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6271 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6272 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6273
6274 { NULL, NULL, NULL, 0, NULL }
6275 };
6276
6277 static DIALOG credits_dlg[] =
6278 {
6279 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6280 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6281 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6282 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6283 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6284 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6285 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6286 };
6287
6288 29 static ListData dmap_list(dmaplist, &font);
6289
6290 static DIALOG goto_dlg[] =
6291 {
6292 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6293 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6294 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6295 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6296 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6297 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6298 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6299 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6300 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6301 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6302 };
6303
6304 int32_t onGoTo()
6305 {
6306 bool music = false;
6307 music = music;
6308 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6309
6310 goto_dlg[0].dp2=get_zc_font(font_lfont);
6311 goto_dlg[4].d2=cheat_goto_dmap;
6312 goto_dlg[6].dp=cheat_goto_screen_str;
6313
6314 clear_keybuf();
6315
6316 large_dialog(goto_dlg);
6317
6318 if(zc_popup_dialog(goto_dlg,4)==1)
6319 {
6320 // dmap, screen
6321 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6322 };
6323
6324 return D_O_K;
6325 }
6326
6327 int32_t onGoToComplete()
6328 {
6329 if(!Playing)
6330 {
6331 return D_O_K;
6332 }
6333
6334 system_pal();
6335 music_pause();
6336 pause_all_sfx();
6337 onGoTo();
6338 eat_buttons();
6339
6340 zc_readrawkey(KEY_ESC);
6341
6342 game_pal();
6343 music_resume();
6344 resume_all_sfx();
6345 return D_O_K;
6346 }
6347
6348 int32_t onCredits()
6349 {
6350 go();
6351
6352 BITMAP *win = create_bitmap_ex(8,222,110);
6353
6354 if(!win)
6355 return D_O_K;
6356
6357 int32_t c=0;
6358 int32_t l=0;
6359 int32_t ol=-1;
6360 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6361 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6362 PALETTE tmppal;
6363
6364 rti_gui.transparency_index = 1;
6365
6366 clear_to_color(win, rti_gui.transparency_index);
6367 draw_rle_sprite(win,rle,0,0);
6368 credits_dlg[0].dp2=get_zc_font(font_lfont);
6369 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6370 credits_dlg[2].dp = win;
6371
6372 zc_set_palette_range(black_palette,0,127,false);
6373
6374 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6375
6376 BITMAP* old_screen = screen;
6377 BITMAP* gui_bmp = zc_get_gui_bmp();
6378 ASSERT(gui_bmp);
6379 clear_to_color(gui_bmp, rti_gui.transparency_index);
6380 screen = gui_bmp;
6381
6382 while(update_dialog(p))
6383 {
6384 throttleFPS();
6385 ++c;
6386 l = zc_max((c>>1)-30,0);
6387
6388 if(l > rle->h)
6389 l = c = 0;
6390
6391 if(l > rle->h - 112)
6392 l = rle->h - 112;
6393
6394 clear_bitmap(win);
6395 draw_rle_sprite(win,rle,0,0-l);
6396
6397 if(c<=64)
6398 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6399
6400 zc_set_palette_range(tmppal,0,127,false);
6401
6402 if(l!=ol)
6403 {
6404 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6405 SCRFIX();
6406 ol=l;
6407 }
6408
6409 update_hw_screen();
6410 }
6411
6412 screen = old_screen;
6413 system_pal();
6414
6415 shutdown_dialog(p);
6416 destroy_bitmap(win);
6417 //comeback();
6418
6419 rti_gui.transparency_index = 0;
6420
6421 return D_O_K;
6422 }
6423
6424 const char *midilist(int32_t index, int32_t *list_size)
6425 {
6426 if(index<0)
6427 {
6428 *list_size=0;
6429
6430 for(int32_t i=0; i<MAXMIDIS; i++)
6431 if(tunes[i].data)
6432 ++(*list_size);
6433
6434 return NULL;
6435 }
6436
6437 int32_t i=0,m=0;
6438
6439 while(m<=index && i<=MAXMIDIS)
6440 {
6441 if(tunes[i].data)
6442 ++m;
6443
6444 ++i;
6445 }
6446
6447 --i;
6448
6449 if(i==MAXMIDIS && m<index)
6450 return "(null)";
6451
6452 return tunes[i].title;
6453 }
6454
6455 /* ------- MIDI info stuff -------- */
6456
6457 char *text;
6458 midi_info *zmi;
6459 bool dialog_running;
6460 bool listening;
6461
6462 void get_info(int32_t index);
6463
6464 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6465 {
6466 int32_t d2 = d->d2;
6467 int32_t ret = jwin_droplist_proc(msg,d,c);
6468
6469 if(d2!=d->d2)
6470 {
6471 get_info(d->d2);
6472 }
6473
6474 return ret;
6475 }
6476
6477 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6478 {
6479 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6480
6481 int32_t ret = jwin_button_proc(msg,d,c);
6482
6483 if(ret == D_CLOSE)
6484 {
6485 // get current midi index
6486 int32_t index = (d+(d->d1))->d2;
6487 int32_t i=0, m=0;
6488
6489 while(m<=index && i<=MAXMIDIS)
6490 {
6491 if(tunes[i].data)
6492 ++m;
6493
6494 ++i;
6495 }
6496
6497 --i;
6498 jukebox(i);
6499 listening = true;
6500 ret = D_O_K;
6501 }
6502
6503 return ret;
6504 }
6505
6506 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6507 {
6508 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6509
6510 int32_t ret = jwin_button_proc(msg,d,c);
6511
6512 if(ret == D_CLOSE)
6513 {
6514 // get current midi index
6515 int32_t index = (d+(d->d1))->d2;
6516 int32_t i=0, m=0;
6517
6518 while(m<=index && i<=MAXMIDIS)
6519 {
6520 if(tunes[i].data)
6521 ++m;
6522
6523 ++i;
6524 }
6525
6526 --i;
6527
6528 // get file name
6529
6530 int32_t sel=0;
6531 //struct ffblk f;
6532 char title[40] = "Save MIDI: ";
6533 char fname[2048];
6534 memset(fname,0,2048);
6535 static EXT_LIST list[] =
6536 {
6537 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6538 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6539 { NULL, NULL }
6540 };
6541
6542 strcpy(title+11, tunes[i].title);
6543 title[39] = '\0';
6544
6545 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6546 goto done;
6547
6548 if(exists(fname))
6549 {
6550 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6551 goto done;
6552 }
6553
6554 // save midi i
6555
6556 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6557 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6558
6559 done:
6560 chop_path(fname);
6561 ret = D_REDRAW;
6562 }
6563
6564 return ret;
6565 }
6566
6567 29 static ListData midi_list(midilist, &font);
6568
6569 static DIALOG midi_dlg[] =
6570 {
6571 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6572 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6573 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6574 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6575 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6576 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6577 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6578 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6579 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6580 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6581 };
6582
6583 void get_info(int32_t index)
6584 {
6585 int32_t i=0, m=0;
6586
6587 while(m<=index && i<=MAXMIDIS)
6588 {
6589 if(tunes[i].data)
6590 ++m;
6591
6592 ++i;
6593 }
6594
6595 --i;
6596
6597 if(i==MAXMIDIS && m<index)
6598 strcpy(text,"(null)");
6599 else
6600 {
6601 get_midi_info((MIDI*)tunes[i].data,zmi);
6602 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6603 }
6604
6605 midi_dlg[0].dp2=get_zc_font(font_lfont);
6606 midi_dlg[3].dp = text;
6607 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6608 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6609
6610 if(dialog_running)
6611 {
6612 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6613 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6614 }
6615 }
6616
6617 int32_t onMIDICredits()
6618 {
6619 text = (char*)malloc(4096);
6620 zmi = (midi_info*)malloc(sizeof(midi_info));
6621
6622 if(!text || !zmi)
6623 {
6624 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6625 return D_O_K;
6626 }
6627
6628 bool do_pause_midi = midi_pos >= 0 && currmidi;
6629 auto restore_midi = currmidi;
6630 if(do_pause_midi)
6631 {
6632 paused_midi_pos = midi_pos;
6633 stop_midi();
6634 midi_paused=true;
6635 midi_suspended = midissuspHALTED;
6636 }
6637
6638 midi_dlg[0].dp2=get_zc_font(font_lfont);
6639 midi_dlg[2].d1 = 0;
6640 midi_dlg[2].d2 = 0;
6641 midi_dlg[4].flags = D_EXIT;
6642 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6643
6644 listening = false;
6645 dialog_running=false;
6646 get_info(0);
6647
6648 dialog_running=true;
6649
6650 large_dialog(midi_dlg);
6651
6652 zc_popup_dialog(midi_dlg,0);
6653 dialog_running=false;
6654
6655 if(listening)
6656 music_stop();
6657
6658 if(do_pause_midi)
6659 {
6660 midi_suspended = midissuspRESUME;
6661 currmidi = restore_midi;
6662 midi_pos = paused_midi_pos;
6663 }
6664
6665 if(text) free(text);
6666 if(zmi) free(zmi);
6667 return D_O_K;
6668 }
6669
6670 int32_t onAbout()
6671 {
6672 char buf1[80]={0};
6673 std::ostringstream oss;
6674 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6675 oss << buf1 << '\n';
6676 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6677 oss << buf1 << '\n';
6678 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6679 oss << buf1 << '\n';
6680 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6681 oss << buf1 << '\n';
6682 sprintf(buf1, "Tag: %s", getReleaseTag());
6683 oss << buf1 << '\n';
6684
6685 InfoDialog("About ZC", oss.str()).show();
6686 return D_O_K;
6687 }
6688
6689 int32_t onQuest()
6690 {
6691 char fname[100];
6692 strcpy(fname, get_filename(qstpath));
6693 quest_dlg[0].dp2=get_zc_font(font_lfont);
6694 quest_dlg[1].dp = fname;
6695
6696 if(QHeader.quest_number==0)
6697 sprintf(str_a,"Custom");
6698 else
6699 sprintf(str_a,"%d",QHeader.quest_number);
6700
6701 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6702
6703 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6704 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6705
6706 large_dialog(quest_dlg);
6707
6708 zc_popup_dialog(quest_dlg, 0);
6709 return D_O_K;
6710 }
6711
6712 void call_vidmode_dlg();
6713 int32_t onVidMode()
6714 {
6715 call_vidmode_dlg();
6716 return D_O_K;
6717 }
6718
6719 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6720 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6721 //Added an extra statement, so that if the key is cleared to 0, the cleared
6722 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6723
6724 void load_ukeys(int32_t* arr)
6725 {
6726 arr[ukey_a] = Akey;
6727 arr[ukey_b] = Bkey;
6728 arr[ukey_s] = Skey;
6729 arr[ukey_l] = Lkey;
6730 arr[ukey_r] = Rkey;
6731 arr[ukey_p] = Pkey;
6732 arr[ukey_ex1] = Exkey1;
6733 arr[ukey_ex2] = Exkey2;
6734 arr[ukey_ex3] = Exkey3;
6735 arr[ukey_ex4] = Exkey4;
6736 arr[ukey_du] = DUkey;
6737 arr[ukey_dd] = DDkey;
6738 arr[ukey_dl] = DLkey;
6739 arr[ukey_dr] = DRkey;
6740 arr[ukey_mod1a] = cheat_modifier_keys[0];
6741 arr[ukey_mod1b] = cheat_modifier_keys[1];
6742 arr[ukey_mod2a] = cheat_modifier_keys[2];
6743 arr[ukey_mod2b] = cheat_modifier_keys[3];
6744 };
6745
6746 static const char* ukey_names[] = {
6747 "A", "B", "Start", "L", "R", "Map",
6748 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6749 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6750 "Cheat Mod R1", "Cheat Mod R2",
6751 };
6752 std::string get_ukey_name(int32_t k)
6753 {
6754 if (k < num_ukey) return ukey_names[k];
6755 return "";
6756 }
6757
6758 int32_t onKeyboard()
6759 {
6760 int32_t a = Akey;
6761 int32_t b = Bkey;
6762 int32_t s = Skey;
6763 int32_t l = Lkey;
6764 int32_t r = Rkey;
6765 int32_t p = Pkey;
6766 int32_t ex1 = Exkey1;
6767 int32_t ex2 = Exkey2;
6768 int32_t ex3 = Exkey3;
6769 int32_t ex4 = Exkey4;
6770 int32_t du = DUkey;
6771 int32_t dd = DDkey;
6772 int32_t dl = DLkey;
6773 int32_t dr = DRkey;
6774 int32_t mod1a = cheat_modifier_keys[0];
6775 int32_t mod1b = cheat_modifier_keys[1];
6776 int32_t mod2a = cheat_modifier_keys[2];
6777 int32_t mod2b = cheat_modifier_keys[3];
6778 bool done=false;
6779 int32_t ret;
6780
6781 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6782
6783 large_dialog(keyboard_control_dlg);
6784
6785 while(!done)
6786 {
6787 ret = zc_popup_dialog(keyboard_control_dlg,3);
6788
6789 if(ret==3) // OK
6790 {
6791 int32_t ukeys[num_ukey];
6792 load_ukeys(ukeys);
6793 std::vector<std::string> uniqueError;
6794 for(int32_t q = 0; q < num_ukey; ++q)
6795 {
6796 for(int32_t p = q+1; p < num_ukey; ++p)
6797 {
6798 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6799 {
6800 char buf[64];
6801 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6802 std::string str(buf);
6803 uniqueError.push_back(str);
6804 }
6805 }
6806 }
6807 if(uniqueError.size() == 0)
6808 {
6809 done = true;
6810 save_control_configs(true);
6811 }
6812 else
6813 {
6814 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6815 box_out("Cannot have duplicate keybinds!"); box_eol();
6816 for(std::vector<std::string>::iterator it = uniqueError.begin();
6817 it != uniqueError.end(); ++it)
6818 {
6819 box_out((*it).c_str()); box_eol();
6820 }
6821 box_end(true);
6822 }
6823 }
6824 else // Cancel
6825 {
6826 Akey = a;
6827 Bkey = b;
6828 Skey = s;
6829 Lkey = l;
6830 Rkey = r;
6831 Pkey = p;
6832 Exkey1 = ex1;
6833 Exkey2 = ex2;
6834 Exkey3 = ex3;
6835 Exkey4 = ex4;
6836 DUkey = du;
6837 DDkey = dd;
6838 DLkey = dl;
6839 DRkey = dr;
6840 cheat_modifier_keys[0] = mod1a;
6841 cheat_modifier_keys[1] = mod1b;
6842 cheat_modifier_keys[2] = mod2a;
6843 cheat_modifier_keys[3] = mod2b;
6844
6845 done=true;
6846 }
6847
6848 rest(1);
6849 }
6850
6851 return D_O_K;
6852 }
6853
6854 int32_t onGamepad()
6855 {
6856 int32_t a = Abtn;
6857 int32_t b = Bbtn;
6858 int32_t s = Sbtn;
6859 int32_t l = Lbtn;
6860 int32_t r = Rbtn;
6861 int32_t m = Mbtn;
6862 int32_t p = Pbtn;
6863 int32_t ex1 = Exbtn1;
6864 int32_t ex2 = Exbtn2;
6865 int32_t ex3 = Exbtn3;
6866 int32_t ex4 = Exbtn4;
6867 int32_t up = DUbtn;
6868 int32_t down = DDbtn;
6869 int32_t left = DLbtn;
6870 int32_t right = DRbtn;
6871
6872 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6873 if(analog_movement)
6874 gamepad_dlg[56].flags|=D_SELECTED;
6875 else
6876 gamepad_dlg[56].flags&=~D_SELECTED;
6877
6878 large_dialog(gamepad_dlg);
6879
6880 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6881
6882 if(ret == 4) //OK
6883 {
6884 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6885 save_control_configs(false);
6886 }
6887 else //Cancel
6888 {
6889 Abtn = a;
6890 Bbtn = b;
6891 Sbtn = s;
6892 Lbtn = l;
6893 Rbtn = r;
6894 Mbtn = m;
6895 Pbtn = p;
6896 Exbtn1 = ex1;
6897 Exbtn2 = ex2;
6898 Exbtn3 = ex3;
6899 Exbtn4 = ex4;
6900 DUbtn = up;
6901 DDbtn = down;
6902 DLbtn = left;
6903 DRbtn = right;
6904 }
6905
6906 return D_O_K;
6907 }
6908
6909 int32_t onCheatKeys()
6910 {
6911 int32_t oldcheats[Cheat::Last][2];
6912 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6913
6914 bool done=false;
6915
6916 while(!done)
6917 {
6918 bool confirm = false;
6919 CheatKeysDialog(&confirm).show();
6920 if(confirm) // OK
6921 {
6922 std::vector<std::string> uniqueError;
6923 char buf[512];
6924 for(size_t q = 1; q < Cheat::Last; ++q)
6925 {
6926 if(cheatkeys[q][1] && !cheatkeys[q][0])
6927 {
6928 cheatkeys[q][0] = cheatkeys[q][1];
6929 cheatkeys[q][1] = 0;
6930 }
6931 }
6932 for(size_t q = 1; q < Cheat::Last; ++q)
6933 {
6934 if(!bindable_cheat((Cheat)q)) continue;
6935 for(size_t p = q+1; p < Cheat::Last; ++p)
6936 {
6937 if(!bindable_cheat((Cheat)p)) continue;
6938 for(size_t q2 = 0; q2 <= 1; ++q2)
6939 for(size_t p2 = 0; p2 <= 1; ++p2)
6940 {
6941 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6942 {
6943 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6944 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6945 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6946 get_keystr(cheatkeys[q][q2])));
6947 }
6948 }
6949 }
6950 }
6951 if(uniqueError.size() == 0)
6952 {
6953 done = true;
6954 save_cheatkeys();
6955 }
6956 else
6957 {
6958 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6959 box_out("Cannot have duplicate keybinds!"); box_eol();
6960 for(std::vector<std::string>::iterator it = uniqueError.begin();
6961 it != uniqueError.end(); ++it)
6962 {
6963 box_out((*it).c_str()); box_eol();
6964 }
6965 box_end(true);
6966 }
6967 }
6968 else // Cancel
6969 {
6970 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6971 done=true;
6972 }
6973 rest(1);
6974 }
6975
6976 return D_O_K;
6977 }
6978
6979 int32_t onSound()
6980 {
6981 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
6982 {
6983 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
6984 }
6985 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
6986 {
6987 master_volume((int32_t)(FFCore.usr_digi_volume),1);
6988 }
6989 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
6990 {
6991 emusic_volume = (int32_t)FFCore.usr_music_volume;
6992 }
6993 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
6994 {
6995 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6996 }
6997 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6998 {
6999 pan_style = (int32_t)FFCore.usr_panstyle;
7000 }
7001
7002 int32_t m = midi_volume;
7003 int32_t d = digi_volume;
7004 int32_t e = emusic_volume;
7005 int32_t b = zcmusic_bufsz;
7006 int32_t s = sfx_volume;
7007 int32_t p = pan_style;
7008 pan_style = vbound(pan_style,0,3);
7009
7010 sound_dlg[0].dp2=get_zc_font(font_lfont);
7011
7012 large_dialog(sound_dlg);
7013
7014 midi_dp[1] = sound_dlg[6].x;
7015 midi_dp[2] = sound_dlg[6].y;
7016 digi_dp[1] = sound_dlg[7].x;
7017 digi_dp[2] = sound_dlg[7].y;
7018 emus_dp[1] = sound_dlg[8].x;
7019 emus_dp[2] = sound_dlg[8].y;
7020 buf_dp[1] = sound_dlg[9].x;
7021 buf_dp[2] = sound_dlg[9].y;
7022 sfx_dp[1] = sound_dlg[10].x;
7023 sfx_dp[2] = sound_dlg[10].y;
7024 pan_dp[1] = sound_dlg[11].x;
7025 pan_dp[2] = sound_dlg[11].y;
7026 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7027 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7028 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7029 sound_dlg[18].d2 = zcmusic_bufsz;
7030 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7031 sound_dlg[20].d2 = pan_style;
7032
7033 int32_t ret = zc_popup_dialog(sound_dlg,1);
7034
7035 if(ret==2)
7036 {
7037 master_volume(digi_volume,midi_volume);
7038
7039 for(int32_t i=0; i<WAV_COUNT; ++i)
7040 {
7041 //allegro assertion fails when passing in -1 as voice -DD
7042 if(sfx_voice[i] > 0)
7043 voice_set_volume(sfx_voice[i], sfx_volume);
7044 }
7045 zc_set_config(sfx_sect,"digi",digi_volume);
7046 zc_set_config(sfx_sect,"midi",midi_volume);
7047 zc_set_config(sfx_sect,"sfx",sfx_volume);
7048 zc_set_config(sfx_sect,"emusic",emusic_volume);
7049 zc_set_config(sfx_sect,"pan",pan_style);
7050 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7051 }
7052 else
7053 {
7054 midi_volume = m;
7055 digi_volume = d;
7056 emusic_volume = e;
7057 zcmusic_bufsz = b;
7058 sfx_volume = s;
7059 pan_style = p;
7060 }
7061
7062 return D_O_K;
7063 }
7064
7065 int32_t queding(char const* s1, char const* s2, char const* s3)
7066 {
7067 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
7068 }
7069
7070 int32_t onQuit()
7071 {
7072 if(Playing)
7073 {
7074 int32_t ret=0;
7075
7076 if(get_bit(quest_rules, qr_NOCONTINUE))
7077 {
7078 if(standalone_mode)
7079 {
7080 ret=queding("End current game?",
7081 "The continue screen is disabled; the game",
7082 "will be reloaded from the last save.");
7083 }
7084 else
7085 {
7086 ret=queding("End current game?",
7087 "The continue screen is disabled. You will",
7088 "be returned to the file select screen.");
7089 }
7090 }
7091 else
7092 ret=queding("End current game?",NULL,NULL);
7093
7094 if(ret==1)
7095 {
7096 disableClickToFreeze=false;
7097 Quit=qQUIT;
7098
7099 // Trying to evade a door repair charge?
7100 if(repaircharge)
7101 {
7102 game->change_drupy(-repaircharge);
7103 repaircharge=0;
7104 }
7105
7106 return D_CLOSE;
7107 }
7108 }
7109
7110 return D_O_K;
7111 }
7112
7113 int32_t onTryQuitMenu()
7114 {
7115 return onTryQuit(true);
7116 }
7117
7118 int32_t onTryQuit(bool inMenu)
7119 {
7120 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7121 {
7122 if(get_bit(quest_rules,qr_OLD_F6))
7123 {
7124 if(inMenu) onQuit();
7125 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7126 }
7127 else
7128 {
7129 disableClickToFreeze=false;
7130 GameFlags |= GAMEFLAG_TRYQUIT;
7131 }
7132 return D_CLOSE;
7133 }
7134
7135 return D_O_K;
7136 }
7137
7138 int32_t onReset()
7139 {
7140 if(queding(" Reset system? ",NULL,NULL)==1)
7141 {
7142 disableClickToFreeze=false;
7143 Quit=qRESET;
7144 replay_quit();
7145 return D_CLOSE;
7146 }
7147
7148 return D_O_K;
7149 }
7150
7151 int32_t onExit()
7152 {
7153 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7154 {
7155 Quit=qEXIT;
7156 return D_CLOSE;
7157 }
7158
7159 return D_O_K;
7160 }
7161
7162 int32_t onTitle_NES()
7163 {
7164 title_version=0;
7165 zc_set_config(cfg_sect,"title",title_version);
7166 return D_O_K;
7167 }
7168 int32_t onTitle_DX()
7169 {
7170 title_version=1;
7171 zc_set_config(cfg_sect,"title",title_version);
7172 return D_O_K;
7173 }
7174 int32_t onTitle_25()
7175 {
7176 title_version=2;
7177 zc_set_config(cfg_sect,"title",title_version);
7178 return D_O_K;
7179 }
7180
7181 int32_t onDebug()
7182 {
7183 if(debug_enabled)
7184 set_debug(!get_debug());
7185 return D_O_K;
7186 }
7187
7188 int32_t onHeartBeep()
7189 {
7190 heart_beep=!heart_beep;
7191 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7192 return D_O_K;
7193 }
7194
7195 int32_t onSaveIndicator()
7196 {
7197 use_save_indicator=!use_save_indicator;
7198 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7199 return D_O_K;
7200 }
7201
7202 int32_t onEpilepsy()
7203 {
7204 if(jwin_alert3(
7205 "Epilepsy Flash Reduction",
7206 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7207 "Disabling this will restore standard flash and wavy behaviour.",
7208 "Proceed?",
7209 "&Yes",
7210 "&No",
7211 NULL,
7212 'y',
7213 'n',
7214 0,
7215 get_zc_font(font_lfont)) == 1)
7216 {
7217 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7218 zc_set_config("zeldadx","checked_epilepsy",1);
7219 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7220 }
7221 return D_O_K;
7222 }
7223
7224 int32_t onTriforce()
7225 {
7226 for(int32_t i=0; i<MAXINITTABS; ++i)
7227 {
7228 init_tabs[i].flags&=~D_SELECTED;
7229 }
7230
7231 init_tabs[3].flags=D_SELECTED;
7232 return onCheatConsole();
7233 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7234 for(int32_t i=1; i<=8; i++)
7235 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7236
7237 if(zc_popup_dialog (triforce_dlg,-1)==9)
7238 {
7239 for(int32_t i=1; i<=8; i++)
7240 {
7241 game->lvlitems[i] &= ~liTRIFORCE;
7242 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7243 }
7244 }
7245 return D_O_K;*/
7246 }
7247
7248 bool rc = false;
7249 /*
7250 int32_t onEquipment()
7251 {
7252 for (int32_t i=0; i<MAXINITTABS; ++i)
7253 {
7254 init_tabs[i].flags&=~D_SELECTED;
7255 }
7256 init_tabs[0].flags=D_SELECTED;
7257 return onCheatConsole();
7258 }
7259 */
7260
7261 int32_t onItems()
7262 {
7263 for(int32_t i=0; i<MAXINITTABS; ++i)
7264 {
7265 init_tabs[i].flags&=~D_SELECTED;
7266 }
7267
7268 init_tabs[1].flags=D_SELECTED;
7269 return onCheatConsole();
7270 }
7271
7272 static DIALOG getnum_dlg[] =
7273 {
7274 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7275 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7276 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7277 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7278 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7279 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7280 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7281 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7282 };
7283
7284 int32_t getnumber(const char *prompt,int32_t initialval)
7285 {
7286 char buf[20];
7287 sprintf(buf,"%d",initialval);
7288 getnum_dlg[0].dp=(void *)prompt;
7289 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7290 getnum_dlg[2].dp=buf;
7291
7292 large_dialog(getnum_dlg);
7293
7294 if(zc_popup_dialog(getnum_dlg,2)==3)
7295 return atoi(buf);
7296
7297 return initialval;
7298 }
7299
7300 int32_t onLife()
7301 {
7302 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7303 cheats_enqueue(Cheat::Life, value);
7304 return D_O_K;
7305 }
7306
7307 int32_t onHeartC()
7308 {
7309 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7310 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7311 cheats_enqueue(Cheat::MaxLife, max_life);
7312 cheats_enqueue(Cheat::Life, life);
7313 return D_O_K;
7314 }
7315
7316 int32_t onMagicC()
7317 {
7318 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7319 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7320 cheats_enqueue(Cheat::MaxMagic, max_magic);
7321 cheats_enqueue(Cheat::Magic, magic);
7322 return D_O_K;
7323 }
7324
7325 int32_t onRupies()
7326 {
7327 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7328 cheats_enqueue(Cheat::Rupies, value);
7329 return D_O_K;
7330 }
7331
7332 int32_t onMaxBombs()
7333 {
7334 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7335 cheats_enqueue(Cheat::MaxBombs, value);
7336 cheats_enqueue(Cheat::Bombs, value);
7337 return D_O_K;
7338 }
7339
7340 int32_t onRefillLife()
7341 {
7342 cheats_enqueue(Cheat::Life, game->get_maxlife());
7343 return D_O_K;
7344 }
7345 int32_t onRefillMagic()
7346 {
7347 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7348 return D_O_K;
7349 }
7350 int32_t onClock()
7351 {
7352 cheats_enqueue(Cheat::Clock);
7353 return D_O_K;
7354 }
7355
7356 int32_t onQstPath()
7357 {
7358 char path[2048];
7359
7360 chop_path(qstdir);
7361 strcpy(path,qstdir);
7362
7363 go();
7364
7365 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7366 {
7367 chop_path(path);
7368 fix_filename_case(path);
7369 fix_filename_slashes(path);
7370 strcpy(qstdir,path);
7371 strcpy(qstpath,qstdir);
7372 }
7373
7374 comeback();
7375 return D_O_K;
7376 }
7377
7378 #include "dialog/cheat_dialog.h"
7379 int32_t onCheat()
7380 {
7381 call_setcheat_dialog();
7382 game->set_cheat(maxcheat);
7383 if(cheat) game->did_cheat(true);
7384 return D_O_K;
7385 }
7386
7387 int32_t onCheatRupies()
7388 {
7389 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7390 return D_O_K;
7391 }
7392
7393 int32_t onCheatArrows()
7394 {
7395 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7396 return D_O_K;
7397 }
7398
7399 int32_t onCheatBombs()
7400 {
7401 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7402 return D_O_K;
7403 }
7404
7405 // *** screen saver
7406
7407 6510614 int32_t after_time()
7408 {
7409
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(ss_enable == 0)
7410 return INT_MAX;
7411
7412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 0)
7413 return 5 * 60;
7414
7415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 3)
7416 return ss_after * 15 * 60;
7417
7418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 13)
7419 return (ss_after - 3) * 60 * 60;
7420
7421 6510614 return MAX_IDLE + 1;
7422 6510614 }
7423
7424 static const char *after_str[15] =
7425 {
7426 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7427 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7428 "Never"
7429 };
7430
7431 const char *after_list(int32_t index, int32_t *list_size)
7432 {
7433 if(index < 0)
7434 {
7435 *list_size = 15;
7436 return NULL;
7437 }
7438
7439 return after_str[index];
7440 }
7441
7442 29 static ListData after__list(after_list, &font);
7443
7444 static DIALOG scrsaver_dlg[] =
7445 {
7446 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7447 29 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7448 29 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7449 29 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7450 29 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7451 29 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7452 29 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7453 29 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7454 29 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7455 29 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7456 29 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7457 29 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7458 29 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7459 29 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7460 };
7461
7462 int32_t onScreenSaver()
7463 {
7464 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7465 int32_t oldcfgs[3];
7466 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7467 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7468 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7469
7470 large_dialog(scrsaver_dlg);
7471
7472 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7473
7474 if(ret == 8 || ret == 9)
7475 {
7476 ss_after = scrsaver_dlg[5].d1;
7477 ss_speed = scrsaver_dlg[6].d2;
7478 ss_density = scrsaver_dlg[7].d2;
7479 if(oldcfgs[0] != ss_after)
7480 zc_set_config(cfg_sect,"ss_after",ss_after);
7481 if(oldcfgs[1] != ss_speed)
7482 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7483 if(oldcfgs[2] != ss_density)
7484 zc_set_config(cfg_sect,"ss_density",ss_density);
7485 }
7486
7487 if(ret == 9)
7488 // preview Screen Saver
7489 {
7490 clear_keybuf();
7491 Matrix(ss_speed, ss_density, 30);
7492 system_pal();
7493 }
7494
7495 return D_O_K;
7496 }
7497
7498 /***** Menus *****/
7499
7500 static MENU game_menu[] =
7501 {
7502 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7503 { (char *)"", NULL, NULL, 0, NULL },
7504 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7505 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7506 { (char *)"", NULL, NULL, 0, NULL },
7507 #ifdef __EMSCRIPTEN__
7508 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7509 #elif defined(ALLEGRO_MACOSX)
7510 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7511 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7512 #else
7513 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7514 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7515 #endif
7516 { NULL, NULL, NULL, 0, NULL }
7517 };
7518
7519 static MENU title_menu[] =
7520 {
7521 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7522 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7523 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7524 { NULL, NULL, NULL, 0, NULL }
7525 };
7526
7527 static MENU snapshot_format_menu[] =
7528 {
7529 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7530 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7531 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7532 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7533 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7534 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7535 { NULL, NULL, NULL, 0, NULL }
7536 };
7537
7538 static MENU controls_menu[] =
7539 {
7540 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7541 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7542 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7543 { NULL, NULL, NULL, 0, NULL }
7544 };
7545
7546 static MENU name_entry_mode_menu[] =
7547 {
7548 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7549 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7550 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7551 { NULL, NULL, NULL, 0, NULL }
7552 };
7553
7554 static void set_controls_menu_active()
7555 {
7556
7557 }
7558
7559 static MENU window_menu[] =
7560 {
7561 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7562 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7563 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7564 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7565 { NULL, NULL, NULL, 0, NULL }
7566 };
7567 static MENU options_menu[] =
7568 {
7569 { "&Title Screen", NULL, title_menu, 0, NULL },
7570 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7571 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7572 { "&Window Settings", NULL, window_menu, 0, NULL },
7573 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7574 { "Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7575 { NULL, NULL, NULL, 0, NULL }
7576 };
7577 static MENU settings_menu[] =
7578 {
7579 { "&Sound...", onSound, NULL, 0, NULL },
7580 { "C&ontrols", NULL, controls_menu, 0, NULL },
7581 { "", NULL, NULL, 0, NULL },
7582 { "Options", NULL, options_menu, 0, NULL },
7583 { "", NULL, NULL, 0, NULL },
7584 //
7585 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7586 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7587 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7588 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7589 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7590 //
7591 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7592 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7593 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7594 { "", NULL, NULL, 0, NULL },
7595 { "Debu&g", onDebug, NULL, 0, NULL },
7596 //
7597 { NULL, NULL, NULL, 0, NULL }
7598 };
7599
7600
7601 static MENU misc_menu[] =
7602 {
7603 { (char *)"&About...", onAbout, NULL, 0, NULL },
7604 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7605 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7606 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7607 { (char *)"", NULL, NULL, 0, NULL },
7608 //5
7609 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7610 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7611 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7612 { (char *)"", NULL, NULL, 0, NULL },
7613 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7614 //10
7615 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7616 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7617 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7618 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7619 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7620 //15
7621 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7622 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7623 { NULL, NULL, NULL, 0, NULL }
7624 };
7625
7626 static MENU refill_menu[] =
7627 {
7628 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7629 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7630 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7631 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7632 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7633 { NULL, NULL, NULL, 0, NULL }
7634 };
7635
7636 static MENU show_menu[] =
7637 {
7638 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7639 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7640 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7641 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7642 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7643 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7644 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7645 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7646 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7647 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7648 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7649 { (char *)"", NULL, NULL, 0, NULL },
7650 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7651 { (char *)"", NULL, NULL, 0, NULL },
7652 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7653 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7654 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7655 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7656 { NULL, NULL, NULL, 0, NULL }
7657 };
7658
7659 static MENU cheat_menu[] =
7660 {
7661 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7662 { (char *)"", NULL, NULL, 0, NULL },
7663 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7664 { (char *)"", NULL, NULL, 0, NULL },
7665 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7666 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7667 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7668 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7669 { (char *)"", NULL, NULL, 0, NULL },
7670 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7671 { (char *)"", NULL, NULL, 0, NULL },
7672 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7673 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7674 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7675 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7676 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7677 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7678 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7679 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7680 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7681 { NULL, NULL, NULL, 0, NULL }
7682 };
7683
7684 #if DEVLEVEL > 0
7685 int32_t devLogging();
7686 int32_t devDebug();
7687 int32_t devTimestmp();
7688 #if DEVLEVEL > 1
7689 int32_t setCheat();
7690 #endif //DEVLEVEL > 1
7691 enum
7692 {
7693 dv_log,
7694 // dv_dbg,
7695 dv_tmpstmp,
7696 #if DEVLEVEL > 1
7697 dv_nil,
7698 dv_setcheat,
7699 #endif //DEVLEVEL > 1
7700 dv_max
7701 };
7702 static MENU dev_menu[] =
7703 {
7704 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7705 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7706 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7707 #if DEVLEVEL > 1
7708 { (char *)"", NULL, NULL, 0, NULL },
7709 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7710 #endif //DEVLEVEL > 1
7711 { NULL, NULL, NULL, 0, NULL }
7712 };
7713 int32_t devLogging()
7714 {
7715 dev_logging = !dev_logging;
7716 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7717 return D_O_K;
7718 }
7719 // int32_t devDebug()
7720 // {
7721 // dev_debug = !dev_debug;
7722 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7723 // return D_O_K;
7724 // }
7725 int32_t devTimestmp()
7726 {
7727 dev_timestmp = !dev_timestmp;
7728 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7729 return D_O_K;
7730 }
7731 #if DEVLEVEL > 1
7732 int32_t setCheat()
7733 {
7734 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7735 return D_O_K;
7736 }
7737 #endif //DEVLEVEL > 1
7738 #endif //DEVLEVEL > 0
7739
7740 MENU the_player_menu[] =
7741 {
7742 { (char *)"&Game", NULL, game_menu, 0, NULL },
7743 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7744 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7745 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7746 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7747 #if DEVLEVEL > 0
7748 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7749 #endif
7750 { NULL, NULL, NULL, 0, NULL }
7751 };
7752 int32_t onMIDIPatch()
7753 {
7754 if(jwin_alert3(
7755 "Toggle Windows MIDI Fix",
7756 "This action will change whether ZC Player auto-restarts a MIDI at its",
7757 "last index if you move ZC Player out of focus, then back into focus.",
7758 "Proceed?",
7759 "&Yes",
7760 "&No",
7761 NULL,
7762 'y',
7763 'n',
7764 0,
7765 get_zc_font(font_lfont)) == 1)
7766 {
7767 midi_patch_fix = midi_patch_fix ? 0 : 1;
7768 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
7769 }
7770 options_menu[5].flags =(midi_patch_fix)?D_SELECTED:0;
7771 return D_O_K;
7772 }
7773
7774 int32_t onKeyboardEntry()
7775 {
7776 NameEntryMode=0;
7777 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7778 return D_O_K;
7779 }
7780
7781 int32_t onLetterGridEntry()
7782 {
7783 NameEntryMode=1;
7784 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7785 return D_O_K;
7786 }
7787
7788 int32_t onExtLetterGridEntry()
7789 {
7790 NameEntryMode=2;
7791 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7792 return D_O_K;
7793 }
7794
7795 static BITMAP* oldscreen;
7796 int32_t onFullscreenMenu()
7797 {
7798 // super hacks
7799 screen = oldscreen;
7800 if (onFullscreen() == D_REDRAW)
7801 {
7802 oldscreen = screen;
7803 }
7804 screen = menu_bmp;
7805 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7806 return D_O_K;
7807 }
7808
7809 29 void fix_menu()
7810 {
7811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!debug_enabled)
7812 29 settings_menu[13].text = NULL;
7813 29 }
7814
7815 static DIALOG system_dlg[] =
7816 {
7817 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7818 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7819 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7820 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7821 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7822 #ifndef ALLEGRO_MACOSX
7823 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7824 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7825 #else
7826 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7827 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7828 #endif
7829 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7830 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7831 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7832 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7833 };
7834
7835 void reset_snapshot_format_menu()
7836 {
7837 for(int32_t i=0; i<ssfmtMAX; ++i)
7838 {
7839 snapshot_format_menu[i].flags=0;
7840 }
7841 }
7842
7843 int32_t onSetSnapshotFormat()
7844 {
7845 switch(active_menu->text[1])
7846 {
7847 case 'B': //"&BMP"
7848 SnapshotFormat=0;
7849 break;
7850
7851 case 'G': //"&GIF"
7852 SnapshotFormat=1;
7853 break;
7854
7855 case 'J': //"&JPG"
7856 SnapshotFormat=2;
7857 break;
7858
7859 case 'P': //"&PNG"
7860 SnapshotFormat=3;
7861 break;
7862
7863 case 'C': //"PC&X"
7864 SnapshotFormat=4;
7865 break;
7866
7867 case 'T': //"&TGA"
7868 SnapshotFormat=5;
7869 break;
7870
7871 case 'L': //"&LBM"
7872 SnapshotFormat=6;
7873 break;
7874 }
7875 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7876
7877 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7878 return D_O_K;
7879 }
7880
7881
7882 43 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7883 {
7884 PALETTE tmp;
7885
7886
2/2
✓ Branch 0 taken 11008 times.
✓ Branch 1 taken 43 times.
11051 for(int32_t i=0; i<256; i++)
7887 {
7888 11008 tmp[i].r=r;
7889 11008 tmp[i].g=g;
7890 11008 tmp[i].b=b;
7891 11008 }
7892
7893 43 fade_interpolate(src,tmp,dest,pos,from,to);
7894 43 }
7895
7896 43 void system_pal()
7897 {
7898 43 is_sys_pal = true;
7899 static PALETTE pal;
7900 43 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
7901
7902 // set up the grayscale palette
7903
2/2
✓ Branch 0 taken 2752 times.
✓ Branch 1 taken 43 times.
2795 for(int32_t i=128; i<192; i++)
7904 {
7905 2752 pal[i].r = i-128;
7906 2752 pal[i].g = i-128;
7907 2752 pal[i].b = i-128;
7908 2752 }
7909 43 load_colorset(gui_colorset, pal, jwin_a5_colors);
7910
7911 43 color_layer(pal, pal, 24,16,16, 28, 128,191);
7912
7913
2/2
✓ Branch 0 taken 5504 times.
✓ Branch 1 taken 43 times.
5547 for(int32_t i=0; i<256; i+=2)
7914 {
7915 5504 int32_t v = (i>>3)+2;
7916 5504 int32_t c = (i>>3)+192;
7917 5504 pal[c] = _RGB(v,v,v+(v>>1));
7918 /*
7919 if(i<240)
7920 {
7921 _allegro_hline(tmp_scr,0,i,319,c);
7922 _allegro_hline(tmp_scr,0,i+1,319,c);
7923 }
7924 */
7925 5504 }
7926
7927 // draw the vertical screen gradient
7928
2/2
✓ Branch 0 taken 10320 times.
✓ Branch 1 taken 43 times.
10363 for(int32_t i=0; i<240; ++i)
7929 {
7930 10320 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
7931 10320 }
7932
7933 /*
7934 palrstart= 10*63/255; palrend=166*63/255;
7935 palgstart= 36*63/255; palgend=202*63/255;
7936 palbstart=106*63/255; palbend=240*63/255;
7937 paldivs=32;
7938 for(int32_t i=0; i<paldivs; i++)
7939 {
7940 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
7941 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
7942 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
7943 }
7944 */
7945 43 BITMAP *panorama = create_bitmap_ex(8,256,224);
7946 int32_t ts_height, ts_start;
7947
7948
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
43 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
7949 {
7950 clear_to_color(panorama,0);
7951 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
7952 ts_height=224-passive_subscreen_height;
7953 ts_start=28;
7954 }
7955 else
7956 {
7957 43 blit(framebuf,panorama,0,0,0,0,256,224);
7958 43 ts_height=224;
7959 43 ts_start=0;
7960 }
7961
7962 // gray scale the current frame
7963
2/2
✓ Branch 0 taken 9632 times.
✓ Branch 1 taken 43 times.
9675 for(int32_t y=0; y<ts_height; y++)
7964 {
7965
2/2
✓ Branch 0 taken 2465792 times.
✓ Branch 1 taken 9632 times.
2475424 for(int32_t x=0; x<256; x++)
7966 {
7967 2465792 int32_t c = panorama->line[y+ts_start][x];
7968
2/2
✓ Branch 0 taken 2459902 times.
✓ Branch 1 taken 5890 times.
2465792 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
7969 2465792 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
7970 2465792 }
7971 9632 }
7972
7973 43 destroy_bitmap(panorama);
7974
7975 // display everything
7976 43 vsync();
7977 43 hw_palette = &pal;
7978 43 update_hw_pal = true;
7979
7980 // sys_pal = pal;
7981 43 memcpy(sys_pal,pal,sizeof(pal));
7982 43 }
7983
7984 void system_pal2()
7985 {
7986 is_sys_pal = true;
7987 static PALETTE RAMpal2;
7988 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
7989
7990 /* Windows 2000 colors
7991 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
7992 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
7993 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
7994 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
7995 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
7996 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
7997 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
7998 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
7999
8000 byte palrstart= 10*63/255, palrend=166*63/255,
8001 palgstart= 36*63/255, palgend=202*63/255,
8002 palbstart=106*63/255, palbend=240*63/255,
8003 paldivs=7;
8004 for(int32_t i=0; i<paldivs; i++)
8005 {
8006 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8007 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8008 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8009 }
8010 */
8011
8012 /* Windows 98 colors
8013 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8014 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8015 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8016 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8017 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8018 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8019 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8020 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8021
8022 byte palrstart= 0*63/255, palrend=166*63/255,
8023 palgstart= 0*63/255, palgend=202*63/255,
8024 palbstart=128*63/255, palbend=240*63/255,
8025 paldivs=7;
8026 for(int32_t i=0; i<paldivs; i++)
8027 {
8028 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8029 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8030 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8031 }
8032 */
8033
8034 /* Windows 99 colors
8035 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8036 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8037 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8038 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8039 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8040 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8041 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8042 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8043 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8044
8045 byte palrstart= 0*63/255, palrend=166*63/255,
8046 palgstart= 0*63/255, palgend=202*63/255,
8047
8048 palbstart=128*63/255, palbend=240*63/255,
8049 paldivs=6;
8050 for(int32_t i=0; i<paldivs; i++)
8051 {
8052 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8053 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8054 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8055 }
8056 */
8057
8058
8059
8060 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8061 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8062 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8063 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8064 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8065 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8066 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8067 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8068 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8069
8070 byte palrstart= 0*63/255, palrend=166*63/255,
8071 palgstart= 0*63/255, palgend=202*63/255,
8072 palbstart=128*63/255, palbend=240*63/255,
8073 paldivs=6;
8074
8075 for(int32_t i=0; i<paldivs; i++)
8076 {
8077 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8078 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8079 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8080 }
8081
8082 gui_bg_color=jwin_pal[jcBOX];
8083 gui_fg_color=jwin_pal[jcBOXFG];
8084
8085 jwin_set_colors(jwin_pal);
8086
8087
8088 // set up the new palette
8089 for(int32_t i=128; i<192; i++)
8090 {
8091 RAMpal2[i].r = i-128;
8092 RAMpal2[i].g = i-128;
8093 RAMpal2[i].b = i-128;
8094 }
8095
8096 /*
8097 for(int32_t i=0; i<64; i++)
8098 {
8099 RAMpal2[128+i] = _RGB(i,i,i)1));
8100 }
8101 */
8102
8103 /*
8104
8105 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8106 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8107 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8108 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8109 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8110 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8111 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8112
8113 gui_fg_color=vc(14);
8114 gui_bg_color=vc(1);
8115
8116 jwin_set_colors(jwin_pal);
8117 */
8118
8119 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8120
8121 // set up the colors for the vertical screen gradient
8122 for(int32_t i=0; i<256; i+=2)
8123 {
8124 int32_t v = (i>>3)+2;
8125 int32_t c = (i>>3)+192;
8126 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8127
8128 /*
8129 if(i<240)
8130 {
8131 _allegro_hline(tmp_scr,0,i,319,c);
8132 _allegro_hline(tmp_scr,0,i+1,319,c);
8133 }
8134 */
8135 }
8136
8137 // hw_palette = &RAMpal;
8138 // update_hw_pal = true;
8139
8140 for(int32_t i=0; i<240; ++i)
8141 {
8142 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8143 }
8144
8145 /*
8146 byte palrstart= 10*63/255, palrend=166*63/255,
8147 palgstart= 36*63/255, palgend=202*63/255,
8148 palbstart=106*63/255, palbend=240*63/255,
8149 paldivs=32;
8150 for(int32_t i=0; i<paldivs; i++)
8151 {
8152 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8153 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8154 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8155 }
8156 */
8157 BITMAP *panorama = create_bitmap_ex(8,256,224);
8158 int32_t ts_height, ts_start;
8159
8160 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8161 {
8162 clear_to_color(panorama,0);
8163 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8164 ts_height=224-passive_subscreen_height;
8165 ts_start=28;
8166 }
8167 else
8168 {
8169 blit(framebuf,panorama,0,0,0,0,256,224);
8170 ts_height=224;
8171 ts_start=0;
8172 }
8173
8174 // gray scale the current frame
8175 for(int32_t y=0; y<ts_height; y++)
8176 {
8177 for(int32_t x=0; x<256; x++)
8178 {
8179 int32_t c = panorama->line[y+ts_start][x];
8180 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8181 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8182 }
8183 }
8184
8185 destroy_bitmap(panorama);
8186
8187 // display everything
8188 vsync();
8189 hw_palette = &RAMpal2;
8190 update_hw_pal = true;
8191
8192 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8193
8194 // sys_pal = pal;
8195 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8196 }
8197
8198 static uint32_t entered_sys_pal = 0;
8199 14 void enter_sys_pal()
8200 {
8201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
8202 {
8203 if(entered_sys_pal)
8204 ++entered_sys_pal;
8205 return;
8206 }
8207 14 system_pal();
8208 14 ++entered_sys_pal;
8209 14 }
8210 14 void exit_sys_pal()
8211 {
8212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
8213 {
8214
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
8215 {
8216 14 game_pal();
8217 14 }
8218 14 }
8219 14 }
8220
8221 void switch_out_callback()
8222 {
8223 if (pause_in_background)
8224 {
8225 callback_switchin = 3;
8226 return;
8227 }
8228
8229 #ifdef _WIN32
8230 if(midi_patch_fix==0 || currmidi==-1)
8231 return;
8232
8233
8234 paused_midi_pos = midi_pos;
8235 zc_stop_midi();
8236 midi_paused=true;
8237 midi_suspended = midissuspHALTED;
8238 #endif
8239 }
8240
8241 void switch_in_callback()
8242 {
8243 if(pause_in_background)
8244 {
8245 return;
8246 }
8247
8248 #ifdef _WIN32
8249 if(midi_patch_fix==0 || currmidi==-1)
8250 return;
8251
8252 else
8253 {
8254 callback_switchin = 1;
8255 midi_suspended = midissuspRESUME;
8256 }
8257 #endif
8258 }
8259
8260 257 void game_pal()
8261 {
8262 257 is_sys_pal = false;
8263 257 entered_sys_pal = 0;
8264 257 clear_to_color(screen,BLACK);
8265 257 hw_palette = &RAMpal;
8266 257 update_hw_pal = true;
8267 257 }
8268
8269 static char bar_str[] = "";
8270
8271 14 void music_pause()
8272 {
8273 //al_pause_duh(tmplayer);
8274 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
8275 14 zc_midi_pause();
8276 14 midi_paused=true;
8277 14 }
8278
8279 void music_resume()
8280 {
8281 //al_resume_duh(tmplayer);
8282 zcmusic_pause(zcmusic, ZCM_RESUME);
8283 zc_midi_resume();
8284 midi_paused=false;
8285 }
8286
8287 5320 void music_stop()
8288 {
8289 //al_stop_duh(tmplayer);
8290 //unload_duh(tmusic);
8291 //tmusic=NULL;
8292 //tmplayer=NULL;
8293 5320 zcmusic_stop(zcmusic);
8294 5320 zcmusic_unload_file(zcmusic);
8295 5320 zc_stop_midi();
8296 5320 midi_paused=false;
8297 5320 currmidi=-1;
8298 5320 }
8299
8300 void System()
8301 {
8302 mouse_down=gui_mouse_b();
8303 music_pause();
8304 pause_all_sfx();
8305 MenuOpen = true;
8306 system_pal();
8307 // FONT *oldfont=font;
8308 // font=tfont;
8309
8310 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8311 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8312
8313 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8314 #if DEVLEVEL > 1
8315 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8316 #endif
8317 game_menu[3].flags =
8318 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8319 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8320 clear_keybuf();
8321
8322 DIALOG_PLAYER *p;
8323
8324 clear_bitmap(menu_bmp);
8325 oldscreen = screen;
8326 screen = menu_bmp;
8327
8328 p = init_dialog(system_dlg,-1);
8329
8330 // drop the menu on startup if menu button pressed
8331 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8332 simulate_keypress(KEY_G << 8);
8333
8334 do
8335 {
8336 if(close_button_quit)
8337 {
8338 close_button_quit = false;
8339 f_Quit(qEXIT);
8340 if(Quit) break;
8341 }
8342 rest(17);
8343
8344 if(mouse_down && !gui_mouse_b())
8345 mouse_down=0;
8346
8347 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8348 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8349 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8350
8351 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8352 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8353 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8354 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
8355 settings_menu[9].flags = TransLayers?D_SELECTED:0;
8356 settings_menu[10].flags = NESquit?D_SELECTED:0;
8357 settings_menu[11].flags = volkeys?D_SELECTED:0;
8358
8359 window_menu[0].flags = DragAspect?D_SELECTED:0;
8360 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
8361 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
8362 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
8363
8364 options_menu[4].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8365 options_menu[5].flags = (midi_patch_fix)?D_SELECTED:0;
8366
8367 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8368 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8369 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8370
8371 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8372 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8373 misc_menu[14].flags =(clearConsoleOnReload)?D_SELECTED:0;
8374 misc_menu[15].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8375
8376 bool nocheat = (replay_is_replaying() || !Playing
8377 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
8378 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
8379 cheat_menu[0].flags = 0;
8380 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8381 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8382 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8383 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8384 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8385 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8386 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8387 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8388 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8389
8390 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8391 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8392 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8393 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8394 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8395 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8396 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8397 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8398 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8399 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8400 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8401 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8402 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8403 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8404 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8405
8406 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
8407 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
8408
8409 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8410 (char *)"Disable recording new saves" :
8411 (char *)"Enable recording new saves";
8412 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8413 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8414 (char *)"Stop recording" :
8415 (char *)"Stop replaying";
8416 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8417 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8418 (char *)"Disable snapshot all frames" :
8419 (char *)"Enable snapshot all frames";
8420
8421 reset_snapshot_format_menu();
8422 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8423
8424 if(debug_enabled)
8425 {
8426 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8427 }
8428
8429 if(gui_mouse_b() && !mouse_down)
8430 break;
8431
8432 // press menu to drop the menu
8433 if(rMbtn())
8434 simulate_keypress(KEY_G << 8);
8435
8436 if(input_idle(true) > after_time())
8437 // run Screeen Saver
8438 {
8439 // Screen saver enabled for now.
8440 clear_keybuf();
8441 Matrix(ss_speed, ss_density, 0);
8442 system_pal();
8443 broadcast_dialog_message(MSG_DRAW, 0);
8444 }
8445
8446 update_hw_screen();
8447 }
8448 while(update_dialog(p));
8449
8450 screen = oldscreen;
8451
8452 // font=oldfont;
8453 mouse_down=gui_mouse_b();
8454 shutdown_dialog(p);
8455 MenuOpen = false;
8456 if(Quit)
8457 {
8458 kill_sfx();
8459 music_stop();
8460 update_hw_screen();
8461 }
8462 else
8463 {
8464 game_pal();
8465 music_resume();
8466 resume_all_sfx();
8467
8468 if(rc)
8469 ringcolor(false);
8470 }
8471
8472 eat_buttons();
8473
8474 rc=false;
8475 clear_keybuf();
8476 // text_mode(0);
8477 }
8478
8479 29 void fix_dialogs()
8480 {
8481 29 jwin_center_dialog(about_dlg);
8482 29 jwin_center_dialog(gamepad_dlg);
8483 29 jwin_center_dialog(credits_dlg);
8484 29 jwin_center_dialog(gamemode_dlg);
8485 29 jwin_center_dialog(getnum_dlg);
8486 29 jwin_center_dialog(goto_dlg);
8487 29 jwin_center_dialog(keyboard_control_dlg);
8488 29 jwin_center_dialog(midi_dlg);
8489 29 jwin_center_dialog(quest_dlg);
8490 29 jwin_center_dialog(scrsaver_dlg);
8491 29 jwin_center_dialog(sound_dlg);
8492 29 jwin_center_dialog(triforce_dlg);
8493
8494 // digi_dp[1] += scrx;
8495 // digi_dp[2] += scry;
8496 // midi_dp[1] += scrx;
8497 // midi_dp[2] += scry;
8498 // pan_dp[1] += scrx;
8499 // pan_dp[2] += scry;
8500 // emus_dp[1] += scrx;
8501 // emus_dp[2] += scry;
8502 // buf_dp[1] += scrx;
8503 // buf_dp[2] += scry;
8504 // sfx_dp[1] += scrx;
8505 // sfx_dp[2] += scry;
8506 29 }
8507
8508 /*****************************/
8509 /**** Custom Sound System ****/
8510 /*****************************/
8511
8512 2295 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8513 {
8514
3/4
✓ Branch 0 taken 2061 times.
✓ Branch 1 taken 234 times.
✓ Branch 2 taken 2295 times.
✗ Branch 3 not taken.
2295 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8515 }
8516
8517 // Run an NSF, or a MIDI if the NSF is missing somehow.
8518 83 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8519 {
8520 83 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8521
8522 // Found it
8523
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 35 times.
83 if(newzcmusic!=NULL)
8524 {
8525 48 zcmusic_stop(zcmusic);
8526 48 zcmusic_unload_file(zcmusic);
8527 48 zc_stop_midi();
8528
8529 48 zcmusic=newzcmusic;
8530 48 zcmusic_play(zcmusic, emusic_volume);
8531
8532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(track>0)
8533 48 zcmusic_change_track(zcmusic,track);
8534
8535 48 return true;
8536 }
8537
8538 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8539
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 else if(midi>-1000)
8540 jukebox(midi);
8541
8542 35 return false;
8543 83 }
8544
8545 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8546 {
8547 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8548 // Found it
8549 if(newzcmusic!=NULL)
8550 {
8551 zcmusic_stop(zcmusic);
8552 zcmusic_unload_file(zcmusic);
8553 zc_stop_midi();
8554
8555 zcmusic=newzcmusic;
8556 zcmusic_play(zcmusic, emusic_volume);
8557
8558 if(track>0)
8559 zcmusic_change_track(zcmusic,track);
8560
8561 return true;
8562 }
8563
8564 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8565 else if(midi>-1000)
8566 jukebox(midi);
8567
8568 return false;
8569 }
8570
8571 int32_t get_zcmusicpos()
8572 {
8573 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8574 return debugtracething;
8575 return 0;
8576 }
8577
8578 void set_zcmusicpos(int32_t position)
8579 {
8580 zcmusic_set_curpos(zcmusic, position);
8581 }
8582
8583 void set_zcmusicspeed(int32_t speed)
8584 {
8585 int32_t newspeed = vbound(speed, 0, 10000);
8586 zcmusic_set_speed(zcmusic, newspeed);
8587 }
8588
8589 1133 void jukebox(int32_t index,int32_t loop)
8590 {
8591 1133 music_stop();
8592
8593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1133 times.
1133 if(index<0) index=MAXMIDIS-1;
8594
8595
1/2
✓ Branch 0 taken 1133 times.
✗ Branch 1 not taken.
1133 if(index>=MAXMIDIS) index=0;
8596
8597 1133 music_stop();
8598
8599 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8600 // stuck notes when a song stops. This fixes it.
8601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1133 times.
1133 if(strcmp(midi_driver->name, "DIGMID")==0)
8602 zc_set_volume(0, 0);
8603
8604 1133 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8605 1133 zc_play_midi((MIDI*)tunes[index].data,loop);
8606
8607
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 377 times.
1133 if(tunes[index].start>0)
8608 377 zc_midi_seek(tunes[index].start);
8609
8610 1133 midi_loop_start = tunes[index].loop_start;
8611 1133 midi_loop_end = tunes[index].loop_end;
8612
8613 1133 currmidi=index;
8614 1133 master_volume(digi_volume,midi_volume);
8615 1133 midi_paused=false;
8616 1133 }
8617
8618 8589 void jukebox(int32_t index)
8619 {
8620
1/2
✓ Branch 0 taken 8589 times.
✗ Branch 1 not taken.
8589 if(index<0) index=MAXMIDIS-1;
8621
8622
1/2
✓ Branch 0 taken 8589 times.
✗ Branch 1 not taken.
8589 if(index>=MAXMIDIS) index=0;
8623
8624 // do nothing if it's already playing
8625
3/4
✓ Branch 0 taken 7456 times.
✓ Branch 1 taken 1133 times.
✓ Branch 2 taken 7456 times.
✗ Branch 3 not taken.
8589 if(index==currmidi && midi_pos>=0)
8626 {
8627 7456 midi_paused=false;
8628 7456 return;
8629 }
8630
8631 1133 jukebox(index,tunes[index].loop);
8632 8589 }
8633
8634 9829 void play_DmapMusic()
8635 {
8636 static char tfile[2048];
8637 static int32_t ttrack=0;
8638 9829 bool domidi=false;
8639
8640
2/2
✓ Branch 0 taken 1330 times.
✓ Branch 1 taken 8499 times.
9829 if(DMaps[currdmap].tmusic[0]!=0)
8641 {
8642
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 945 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1715 if(zcmusic==NULL ||
8643
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8644
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8645 {
8646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945 times.
945 if(zcmusic != NULL)
8647 {
8648 zcmusic_stop(zcmusic);
8649 zcmusic_unload_file(zcmusic);
8650 zcmusic = NULL;
8651 }
8652
8653 945 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8654
8655
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 859 times.
945 if(zcmusic!=NULL)
8656 {
8657 86 zc_stop_midi();
8658 86 strcpy(tfile,DMaps[currdmap].tmusic);
8659 86 zcmusic_play(zcmusic, emusic_volume);
8660 86 int32_t temptracks=0;
8661 86 temptracks=zcmusic_get_tracks(zcmusic);
8662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
8663 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8664 86 zcmusic_change_track(zcmusic,ttrack);
8665 86 }
8666 else
8667 {
8668 859 tfile[0] = 0;
8669 859 domidi=true;
8670 }
8671 945 }
8672 1330 }
8673 else
8674 {
8675 8499 domidi=true;
8676 }
8677
8678
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 9358 times.
9829 if(domidi)
8679 {
8680 9358 int32_t m=DMaps[currdmap].midi;
8681
8682
3/4
✓ Branch 0 taken 9243 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
9358 switch(m)
8683 {
8684 case 1:
8685 105 jukebox(ZC_MIDI_OVERWORLD);
8686 105 break;
8687
8688 case 2:
8689 10 jukebox(ZC_MIDI_DUNGEON);
8690 10 break;
8691
8692 case 3:
8693 jukebox(ZC_MIDI_LEVEL9);
8694 break;
8695
8696 default:
8697
3/4
✓ Branch 0 taken 8329 times.
✓ Branch 1 taken 914 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8329 times.
9243 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8698 8329 jukebox(m+MIDIOFFSET_DMAP);
8699 else
8700 914 music_stop();
8701 9243 }
8702 9358 }
8703 9829 }
8704
8705 9866 void playLevelMusic()
8706 {
8707 9866 int32_t m=tmpscr->screen_midi;
8708
8709
3/6
✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
9866 switch(m)
8710 {
8711 case -2:
8712 12 music_stop();
8713 12 break;
8714
8715 case -1:
8716 9813 play_DmapMusic();
8717 9813 break;
8718
8719 case 1:
8720 jukebox(ZC_MIDI_OVERWORLD);
8721 break;
8722
8723 case 2:
8724 jukebox(ZC_MIDI_DUNGEON);
8725 break;
8726
8727 case 3:
8728 jukebox(ZC_MIDI_LEVEL9);
8729 break;
8730
8731 default:
8732
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8733 41 jukebox(m+MIDIOFFSET_MAPSCR);
8734 else
8735 music_stop();
8736 41 }
8737 9866 }
8738
8739 1162 void master_volume(int32_t dv,int32_t mv)
8740 {
8741
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1162 times.
✓ Branch 2 taken 1162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1162 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1162 times.
✗ Branch 7 not taken.
1162 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8742
8743
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1162 times.
✓ Branch 2 taken 1162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1162 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1162 times.
✗ Branch 7 not taken.
1162 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8744
8745
6/6
✓ Branch 0 taken 1132 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 1160 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1130 times.
✓ Branch 5 taken 30 times.
1162 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8746 1162 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
8747 1162 }
8748
8749 /*****************/
8750 /***** SFX *****/
8751 /*****************/
8752
8753 // array of voices, one for each sfx sample in the data file
8754 // 0+ = voice #
8755 // -1 = voice not allocated
8756 29 void Z_init_sound()
8757 {
8758
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i=0; i<WAV_COUNT; i++)
8759 7424 sfx_voice[i]=-1;
8760
8761
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 29 times.
232 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8762 203 tunes[i].data = (MIDI*)mididata[i].dat;
8763
8764
2/2
✓ Branch 0 taken 7308 times.
✓ Branch 1 taken 29 times.
7337 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8765 7308 tunes[ZC_MIDI_COUNT+j].data=NULL;
8766
8767 29 master_volume(digi_volume,midi_volume);
8768 29 }
8769
8770 // returns number of voices currently allocated
8771 int32_t sfx_count()
8772 {
8773 int32_t c=0;
8774
8775 for(int32_t i=0; i<WAV_COUNT; i++)
8776 if(sfx_voice[i]!=-1)
8777 ++c;
8778
8779 return c;
8780 }
8781
8782 // clean up finished samples
8783 6480723 void sfx_cleanup()
8784 {
8785
2/2
✓ Branch 0 taken 1659065088 times.
✓ Branch 1 taken 6480723 times.
1665545811 for(int32_t i=0; i<WAV_COUNT; i++)
8786
3/4
✓ Branch 0 taken 560755 times.
✓ Branch 1 taken 1658504333 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 560755 times.
1659625843 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8787 {
8788 560755 deallocate_voice(sfx_voice[i]);
8789 560755 sfx_voice[i]=-1;
8790 560755 }
8791 6480723 }
8792
8793 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8794 // if a voice is already allocated (and/or playing), then it just returns true
8795 // Returns true: voice is allocated
8796 // false: unsuccessful
8797 838762 bool sfx_init(int32_t index)
8798 {
8799 // check index
8800
3/4
✓ Branch 0 taken 620761 times.
✓ Branch 1 taken 218001 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 620761 times.
838762 if(index<=0 || index>=WAV_COUNT)
8801 218001 return false;
8802
8803
2/2
✓ Branch 0 taken 59980 times.
✓ Branch 1 taken 560781 times.
620761 if(sfx_voice[index]==-1)
8804 {
8805
2/2
✓ Branch 0 taken 110294 times.
✓ Branch 1 taken 450487 times.
560781 if(sfxdat)
8806 {
8807
1/2
✓ Branch 0 taken 110294 times.
✗ Branch 1 not taken.
110294 if(index<Z35)
8808 {
8809 110294 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8810 110294 }
8811 else
8812 {
8813 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8814 }
8815 110294 }
8816 else
8817 {
8818 450487 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8819 }
8820
8821 560781 voice_set_volume(sfx_voice[index], sfx_volume);
8822 560781 }
8823
8824 620761 return sfx_voice[index] != -1;
8825 838762 }
8826
8827 // plays an sfx sample
8828 732250 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
8829 {
8830
2/2
✓ Branch 0 taken 550996 times.
✓ Branch 1 taken 181254 times.
732250 if(!sfx_init(index))
8831 181254 return;
8832
8833 550996 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8834 550996 voice_set_pan(sfx_voice[index],pan);
8835
8836 550996 int32_t pos = voice_get_position(sfx_voice[index]);
8837
8838
2/2
✓ Branch 0 taken 259936 times.
✓ Branch 1 taken 291060 times.
550996 if(restart) voice_set_position(sfx_voice[index],0);
8839
8840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550996 times.
550996 if(pos<=0)
8841 550996 voice_start(sfx_voice[index]);
8842
8843
3/4
✓ Branch 0 taken 291060 times.
✓ Branch 1 taken 259936 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 291060 times.
550996 if (restart && replay_is_debug())
8844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291060 times.
291060 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8845 732250 }
8846
8847 // true if sfx is allocated
8848 32243 bool sfx_allocated(int32_t index)
8849 {
8850
3/4
✓ Branch 0 taken 9403 times.
✓ Branch 1 taken 22840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9403 times.
32243 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8851 }
8852
8853 // start it (in loop mode) if it's not already playing,
8854 // otherwise adjust it to play in loop mode -DD
8855 106512 void cont_sfx(int32_t index)
8856 {
8857
2/2
✓ Branch 0 taken 36747 times.
✓ Branch 1 taken 69765 times.
106512 if(!sfx_init(index))
8858 {
8859 36747 return;
8860 }
8861
8862
1/2
✓ Branch 0 taken 69765 times.
✗ Branch 1 not taken.
69765 if(voice_get_position(sfx_voice[index])<=0)
8863 {
8864 69765 voice_set_position(sfx_voice[index],0);
8865 69765 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8866 69765 voice_start(sfx_voice[index]);
8867 69765 }
8868 else
8869 {
8870 adjust_sfx(index, 128, true);
8871 }
8872 106512 }
8873
8874 // adjust parameters while playing
8875 3547 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8876 {
8877
5/6
✓ Branch 0 taken 2124 times.
✓ Branch 1 taken 1423 times.
✓ Branch 2 taken 2124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 2110 times.
3547 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8878 3533 return;
8879
8880 14 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8881 14 voice_set_pan(sfx_voice[index],pan);
8882 3547 }
8883
8884 // pauses a voice
8885 1468 void pause_sfx(int32_t index)
8886 {
8887
3/6
✓ Branch 0 taken 1468 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1468 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1468 times.
1468 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8888 voice_stop(sfx_voice[index]);
8889 1468 }
8890
8891 // resumes a voice
8892 637 void resume_sfx(int32_t index)
8893 {
8894
3/6
✓ Branch 0 taken 637 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 637 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 637 times.
637 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8895 voice_start(sfx_voice[index]);
8896 637 }
8897
8898 // pauses all active voices
8899 244 void pause_all_sfx()
8900 {
8901
2/2
✓ Branch 0 taken 62464 times.
✓ Branch 1 taken 244 times.
62708 for(int32_t i=0; i<WAV_COUNT; i++)
8902
2/2
✓ Branch 0 taken 62462 times.
✓ Branch 1 taken 2 times.
62466 if(sfx_voice[i]!=-1)
8903 2 voice_stop(sfx_voice[i]);
8904 244 }
8905
8906 // resumes all paused voices
8907 230 void resume_all_sfx()
8908 {
8909
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 230 times.
59110 for(int32_t i=0; i<WAV_COUNT; i++)
8910
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(sfx_voice[i]!=-1)
8911 voice_start(sfx_voice[i]);
8912 230 }
8913
8914 // stops an sfx and deallocates the voice
8915 5203476 void stop_sfx(int32_t index)
8916 {
8917
3/4
✓ Branch 0 taken 5102116 times.
✓ Branch 1 taken 101360 times.
✓ Branch 2 taken 5102116 times.
✗ Branch 3 not taken.
5203476 if(index<=0 || index>=WAV_COUNT)
8918 101360 return;
8919
8920
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5102103 times.
5102116 if(sfx_voice[index]!=-1)
8921 {
8922 13 deallocate_voice(sfx_voice[index]);
8923 13 sfx_voice[index]=-1;
8924 13 }
8925 5203476 }
8926
8927 // Stops SFX played by Hero's item of the given family
8928 131169 void stop_item_sfx(int32_t family)
8929 {
8930 131169 int32_t id=current_item_id(family);
8931
8932
2/2
✓ Branch 0 taken 130841 times.
✓ Branch 1 taken 328 times.
131169 if(id<0)
8933 130841 return;
8934
8935 328 stop_sfx(itemsbuf[id].usesound);
8936 131169 }
8937
8938 1802 void kill_sfx()
8939 {
8940
2/2
✓ Branch 0 taken 461312 times.
✓ Branch 1 taken 1802 times.
463114 for(int32_t i=0; i<WAV_COUNT; i++)
8941
2/2
✓ Branch 0 taken 461299 times.
✓ Branch 1 taken 13 times.
461325 if(sfx_voice[i]!=-1)
8942 {
8943 13 deallocate_voice(sfx_voice[i]);
8944 13 sfx_voice[i]=-1;
8945 13 }
8946 1802 }
8947
8948 504198 int32_t pan(int32_t x)
8949 {
8950
1/4
✓ Branch 0 taken 504198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
504198 switch(pan_style)
8951 {
8952 case 0:
8953 return 128;
8954
8955 case 1:
8956 504198 return vbound((x>>1)+68,0,255);
8957
8958 case 2:
8959 return vbound(((x*3)>>2)+36,0,255);
8960 }
8961
8962 return vbound(x,0,255);
8963 504198 }
8964
8965 /*******************************/
8966 /******* Input Handlers ********/
8967 /*******************************/
8968
8969 16584516 bool joybtn(int32_t b)
8970 {
8971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16584516 times.
16584516 if(b == 0)
8972 return false;
8973
8974 16584516 return joy[joystick_index].button[b-1].b !=0;
8975 16584516 }
8976
8977 const char* joybtn_name(int32_t b)
8978 {
8979 if(b == 0)
8980 return "";
8981
8982 return joy[joystick_index].button[b-1].name;
8983 }
8984
8985 int32_t next_press_key();
8986
8987 int32_t next_press_btn()
8988 {
8989 clear_keybuf();
8990 /*bool b[joy[joystick_index].num_buttons+1];
8991
8992 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8993 b[i]=joybtn(i);*/
8994
8995 //first, we need to wait until they're pressing no buttons
8996 for(;;)
8997 {
8998 if(keypressed())
8999 {
9000 switch(readkey()>>8)
9001 {
9002 case KEY_ESC:
9003 return -1;
9004
9005 case KEY_SPACE:
9006 return 0;
9007 }
9008 }
9009
9010 poll_joystick();
9011 bool done = true;
9012
9013 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9014 {
9015 if(joybtn(i)) done = false;
9016 }
9017
9018 if(done) break;
9019 rest(1);
9020 }
9021
9022 //now, we need to wait for them to press any button
9023 for(;;)
9024 {
9025 if(keypressed())
9026 {
9027 switch(readkey()>>8)
9028 {
9029 case KEY_ESC:
9030 return -1;
9031
9032 case KEY_SPACE:
9033 return 0;
9034 }
9035 }
9036
9037 poll_joystick();
9038
9039 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9040 {
9041 if(joybtn(i)) return i;
9042 }
9043 rest(1);
9044 }
9045 }
9046
9047 134574253 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9048 {
9049
2/2
✓ Branch 0 taken 129784481 times.
✓ Branch 1 taken 4789772 times.
134574253 bool ret = btn && !flag;
9050
2/2
✓ Branch 0 taken 117573131 times.
✓ Branch 1 taken 17001122 times.
134574253 flag = rawbtn ? *rawbtn : btn;
9051
9052 134574253 return ret;
9053 }
9054 1337132 static bool rButtonPeek(bool btn, bool flag)
9055 {
9056
2/2
✓ Branch 0 taken 1249424 times.
✓ Branch 1 taken 87708 times.
1337132 if(!btn)
9057 {
9058 1249424 return false;
9059 }
9060
2/2
✓ Branch 0 taken 14956 times.
✓ Branch 1 taken 72752 times.
87708 else if(!flag)
9061 {
9062 14956 return true;
9063 }
9064
9065 72752 return false;
9066 1337132 }
9067
9068 // Updated only by keyboard/gamepad.
9069 // If in replay mode, this is set directly by the replay system.
9070 // This should never be read from directly - use control_state instead.
9071 bool raw_control_state[ZC_CONTROL_STATES];
9072
9073 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9074 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9075 // lasts until the next call to load_control_state.
9076 bool control_state[ZC_CONTROL_STATES];
9077 bool disable_control[ZC_CONTROL_STATES];
9078 bool drunk_toggle_state[11];
9079 bool disabledKeys[127];
9080 bool KeyInput[127];
9081 bool KeyPress[127];
9082
9083 bool key_current_frame[127];
9084 bool key_previous_frame[127];
9085
9086 static bool key_system[127];
9087 static bool key_system_previous[127];
9088 static bool key_system_press[127];
9089
9090 bool button_press[ZC_CONTROL_STATES];
9091 bool button_hold[ZC_CONTROL_STATES];
9092
9093 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9094 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9095 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9096 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9097 #define STICK_PRECISION 56 //define your own sensitivity
9098
9099 5438197 void load_control_state()
9100 {
9101 5438197 load_control_called_this_frame = true;
9102
9103
3/4
✓ Branch 0 taken 2566996 times.
✓ Branch 1 taken 2871201 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2566996 times.
5438197 if (replay_get_version() >= 8 && replay_get_version() < 11)
9104 {
9105
2/2
✓ Branch 0 taken 46205928 times.
✓ Branch 1 taken 2566996 times.
48772924 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9106 46205928 down_control_states[i] = raw_control_state[i];
9107 2566996 }
9108
9109
1/2
✓ Branch 0 taken 5438197 times.
✗ Branch 1 not taken.
5438197 if (!replay_is_replaying())
9110 {
9111 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9112 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9113 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9114 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9115 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9116 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9117 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9118 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9119 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9120 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9121 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9122 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9123 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9124 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9125
9126 if(num_joysticks != 0)
9127 {
9128 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9129 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9130 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9131 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9132 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9133 }
9134 else
9135 {
9136 raw_control_state[14] = false;
9137 raw_control_state[15] = false;
9138 raw_control_state[16] = false;
9139 raw_control_state[17] = false;
9140 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9141 }
9142 }
9143
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5438194 times.
5438197 if (replay_is_active())
9144 {
9145
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 4422979 times.
5438194 if (replay_get_version() < 3)
9146 1015215 replay_poll();
9147
3/4
✓ Branch 0 taken 4422979 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2661604 times.
✓ Branch 3 taken 1761375 times.
4422979 else if (replay_is_replaying() && replay_get_version() < 6)
9148 1761375 replay_peek_input();
9149
4/6
✓ Branch 0 taken 2661604 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2566996 times.
✓ Branch 3 taken 94608 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2566996 times.
2661604 else if (replay_is_replaying() && replay_get_version() >= 8 && replay_get_version() < 11)
9150 2566996 replay_peek_input();
9151
2/2
✓ Branch 0 taken 4320728 times.
✓ Branch 1 taken 1117466 times.
5438194 if (replay_get_version() == 8)
9152 1117466 update_keys();
9153 5438194 }
9154
9155 // Some test replay files were made before a serious input bug was fixed, so instead
9156 // of re-doing them or tossing them out, just check for that zplay version.
9157
3/4
✓ Branch 0 taken 5438191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 5316291 times.
5438197 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9158
2/2
✓ Branch 0 taken 97887438 times.
✓ Branch 1 taken 5438191 times.
103325629 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9159 {
9160 97887438 control_state[i] = raw_control_state[i];
9161
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 48400128 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
97887438 if (botched_input && !control_state[i])
9162 47077142 down_control_states[i] = false;
9163 97887438 }
9164
9165 5438191 button_press[0]=rButton(control_state[0],button_hold[0]);
9166 5438191 button_press[1]=rButton(control_state[1],button_hold[1]);
9167 5438191 button_press[2]=rButton(control_state[2],button_hold[2]);
9168 5438191 button_press[3]=rButton(control_state[3],button_hold[3]);
9169 5438191 button_press[4]=rButton(control_state[4],button_hold[4]);
9170 5438191 button_press[5]=rButton(control_state[5],button_hold[5]);
9171 5438191 button_press[6]=rButton(control_state[6],button_hold[6]);
9172 5438191 button_press[7]=rButton(control_state[7],button_hold[7]);
9173 5438191 button_press[8]=rButton(control_state[8],button_hold[8]);
9174 5438191 button_press[9]=rButton(control_state[9],button_hold[9]);
9175 5438191 button_press[10]=rButton(control_state[10],button_hold[10]);
9176 5438191 button_press[11]=rButton(control_state[11],button_hold[11]);
9177 5438191 button_press[12]=rButton(control_state[12],button_hold[12]);
9178 5438191 button_press[13]=rButton(control_state[13],button_hold[13]);
9179 5438191 button_press[14]=rButton(control_state[14],button_hold[14]);
9180 5438191 button_press[15]=rButton(control_state[15],button_hold[15]);
9181 5438191 button_press[16]=rButton(control_state[16],button_hold[16]);
9182 5438191 button_press[17]=rButton(control_state[17],button_hold[17]);
9183 5438191 }
9184
9185 // Returns true if any game key is pressed. This is needed because keypressed()
9186 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9187 28178162 bool zc_key_pressed()
9188 //may also need to use zc_getrawkey
9189 {
9190
7/10
✓ Branch 0 taken 22800161 times.
✓ Branch 1 taken 5378001 times.
✓ Branch 2 taken 5378001 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5378001 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4533401 times.
✓ Branch 7 taken 4533401 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1621032 times.
29799194 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9191
4/6
✓ Branch 0 taken 4533401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4533401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3418530 times.
✓ Branch 5 taken 3418530 times.
4533401 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9192
4/6
✓ Branch 0 taken 3418530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3418530 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2176173 times.
✓ Branch 5 taken 2176173 times.
3418530 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9193
4/6
✓ Branch 0 taken 2176173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2176173 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1838283 times.
✓ Branch 5 taken 1838283 times.
2176173 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9194
1/2
✓ Branch 0 taken 1838283 times.
✗ Branch 1 not taken.
1838283 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9195
3/4
✓ Branch 0 taken 1736661 times.
✓ Branch 1 taken 101622 times.
✓ Branch 2 taken 1736661 times.
✗ Branch 3 not taken.
1838283 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9196
3/4
✓ Branch 0 taken 1646160 times.
✓ Branch 1 taken 90501 times.
✓ Branch 2 taken 1646160 times.
✗ Branch 3 not taken.
1736661 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9197
3/4
✓ Branch 0 taken 1633476 times.
✓ Branch 1 taken 12684 times.
✓ Branch 2 taken 1633476 times.
✗ Branch 3 not taken.
1646160 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9198
3/4
✓ Branch 0 taken 1623117 times.
✓ Branch 1 taken 10359 times.
✓ Branch 2 taken 1623117 times.
✗ Branch 3 not taken.
1633476 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9199
3/4
✓ Branch 0 taken 1621864 times.
✓ Branch 1 taken 1253 times.
✓ Branch 2 taken 1621864 times.
✗ Branch 3 not taken.
1623117 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9200
3/4
✓ Branch 0 taken 1621821 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 1621821 times.
✗ Branch 3 not taken.
1621864 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9201
3/4
✓ Branch 0 taken 1621051 times.
✓ Branch 1 taken 770 times.
✓ Branch 2 taken 1621051 times.
✗ Branch 3 not taken.
1621821 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9202
2/4
✓ Branch 0 taken 1621051 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621051 times.
✗ Branch 3 not taken.
1621051 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9203
2/2
✓ Branch 0 taken 1621032 times.
✓ Branch 1 taken 19 times.
1621051 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9204 50489904 return true;
9205
9206 1621032 return false;
9207 6510614 }
9208
9209 108529366 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9210 {
9211 108529366 bool ret = false, drunkstate = false, rawret = false;
9212 108529366 bool* flag = &down_control_states[btn];
9213
2/7
✓ Branch 0 taken 102011933 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 6517433 times.
108529366 switch(btn)
9214 {
9215 case btnF12:
9216 ret = zc_getkey(KEY_F12, ignoreDisable);
9217 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9218 eatEntirely = false;
9219 break;
9220 case btnF11:
9221 ret = zc_getkey(KEY_F11, ignoreDisable);
9222 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9223 eatEntirely = false;
9224 break;
9225 case btnF5:
9226 ret = zc_getkey(KEY_F5, ignoreDisable);
9227 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9228 eatEntirely = false;
9229 break;
9230 case btnQ:
9231 ret = zc_getkey(KEY_Q, ignoreDisable);
9232 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9233 eatEntirely = false;
9234 break;
9235 case btnI:
9236 ret = zc_getkey(KEY_I, ignoreDisable);
9237 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9238 eatEntirely = false;
9239 break;
9240 case btnM:
9241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6517433 times.
6517433 if(FFCore.kb_typing_mode) return false;
9242 6517433 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9243 6517433 eatEntirely = false;
9244 6517433 break;
9245 default: //control_state[] index
9246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102011933 times.
102011933 if(FFCore.kb_typing_mode) return false;
9247
5/6
✓ Branch 0 taken 101784203 times.
✓ Branch 1 taken 227730 times.
✓ Branch 2 taken 2257162 times.
✓ Branch 3 taken 99527041 times.
✓ Branch 4 taken 2257162 times.
✗ Branch 5 not taken.
102011933 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9248
2/2
✓ Branch 0 taken 5491613 times.
✓ Branch 1 taken 96520320 times.
102011933 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9249
4/4
✓ Branch 0 taken 91845546 times.
✓ Branch 1 taken 10166387 times.
✓ Branch 2 taken 1395 times.
✓ Branch 3 taken 10164992 times.
112178320 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9250 102011933 rawret = raw_control_state[btn];
9251 102011933 }
9252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108529366 times.
108529366 assert(flag);
9253
2/2
✓ Branch 0 taken 70505419 times.
✓ Branch 1 taken 38023947 times.
108529366 if(press)
9254 {
9255
2/2
✓ Branch 0 taken 1337132 times.
✓ Branch 1 taken 36686815 times.
38023947 if(peek)
9256 1337132 ret = rButtonPeek(ret, *flag);
9257
3/4
✓ Branch 0 taken 36686815 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17001122 times.
✓ Branch 3 taken 19685693 times.
36686815 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9258 17001122 else ret = rButton(ret, *flag, &rawret);
9259 38023947 }
9260
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 108529366 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
108529366 if(eatEntirely && ret) control_state[btn] = false;
9261
3/4
✓ Branch 0 taken 82010678 times.
✓ Branch 1 taken 26518688 times.
✓ Branch 2 taken 82010678 times.
✗ Branch 3 not taken.
108529366 if(drunk && drunkstate) ret = !ret;
9262 108529366 return ret;
9263 108529366 }
9264
9265 5384201 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9266 {
9267 5384201 byte ret = 0;
9268
2/2
✓ Branch 0 taken 4045008 times.
✓ Branch 1 taken 1339193 times.
5384201 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9269
2/2
✓ Branch 0 taken 5383639 times.
✓ Branch 1 taken 562 times.
5384201 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9270
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9271
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9272
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9273
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9274
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9275
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9276 5384201 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9277 }
9278
9279 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9280 {
9281 1114 return intbtn&vals;
9282 }
9283
9284 1281348 bool Up()
9285 {
9286 1281348 return getInput(btnUp);
9287 }
9288 77421 bool Down()
9289 {
9290 77421 return getInput(btnDown);
9291 }
9292 167324 bool Left()
9293 {
9294 167324 return getInput(btnLeft);
9295 }
9296 188659 bool Right()
9297 {
9298 188659 return getInput(btnRight);
9299 }
9300 68115 bool cAbtn()
9301 {
9302 68115 return getInput(btnA);
9303 }
9304 1255212 bool cBbtn()
9305 {
9306 1255212 return getInput(btnB);
9307 }
9308 bool cSbtn()
9309 {
9310 return getInput(btnS);
9311 }
9312 29891 bool cLbtn()
9313 {
9314 29891 return getInput(btnL);
9315 }
9316 29891 bool cRbtn()
9317 {
9318 29891 return getInput(btnR);
9319 }
9320 bool cPbtn()
9321 {
9322 return getInput(btnP);
9323 }
9324 bool cEx1btn()
9325 {
9326 return getInput(btnEx1);
9327 }
9328 bool cEx2btn()
9329 {
9330 return getInput(btnEx2);
9331 }
9332 bool cEx3btn()
9333 {
9334 return getInput(btnEx3);
9335 }
9336 bool cEx4btn()
9337 {
9338 return getInput(btnEx4);
9339 }
9340 bool AxisUp()
9341 {
9342 return getInput(btnAxisUp);
9343 }
9344 bool AxisDown()
9345 {
9346 return getInput(btnAxisDown);
9347 }
9348 bool AxisLeft()
9349 {
9350 return getInput(btnAxisLeft);
9351 }
9352 bool AxisRight()
9353 {
9354 return getInput(btnAxisRight);
9355 }
9356
9357 bool cMbtn()
9358 {
9359 return getInput(btnM);
9360 }
9361 bool cF12()
9362 {
9363 return getInput(btnF12);
9364 }
9365 bool cF11()
9366 {
9367 return getInput(btnF11);
9368 }
9369 bool cF5()
9370 {
9371 return getInput(btnF5);
9372 }
9373 bool cQ()
9374 {
9375 return getInput(btnQ);
9376 }
9377 bool cI()
9378 {
9379 return getInput(btnI);
9380 }
9381
9382 112876 bool rUp()
9383 {
9384 112876 return getInput(btnUp, true);
9385 }
9386 112804 bool rDown()
9387 {
9388 112804 return getInput(btnDown, true);
9389 }
9390 112757 bool rLeft()
9391 {
9392 112757 return getInput(btnLeft, true);
9393 }
9394 112309 bool rRight()
9395 {
9396 112309 return getInput(btnRight, true);
9397 }
9398 2482 bool rAbtn()
9399 {
9400 2482 return getInput(btnA, true);
9401 }
9402 113491 bool rBbtn()
9403 {
9404 113491 return getInput(btnB, true);
9405 }
9406 5266505 bool rSbtn()
9407 {
9408 5266505 return getInput(btnS, true);
9409 }
9410 6510614 bool rMbtn()
9411 {
9412 6510614 return getInput(btnM, true);
9413 }
9414 112109 bool rLbtn()
9415 {
9416 112109 return getInput(btnL, true);
9417 }
9418 112106 bool rRbtn()
9419 {
9420 112106 return getInput(btnR, true);
9421 }
9422 5182404 bool rPbtn()
9423 {
9424 5182404 return getInput(btnP, true);
9425 }
9426 bool rEx1btn()
9427 {
9428 return getInput(btnEx1, true);
9429 }
9430 bool rEx2btn()
9431 {
9432 return getInput(btnEx2, true);
9433 }
9434 122985 bool rEx3btn()
9435 {
9436 122985 return getInput(btnEx3, true);
9437 }
9438 122985 bool rEx4btn()
9439 {
9440 122985 return getInput(btnEx4, true);
9441 }
9442 bool rAxisUp()
9443 {
9444 return getInput(btnAxisUp, true);
9445 }
9446 bool rAxisDown()
9447 {
9448 return getInput(btnAxisDown, true);
9449 }
9450 bool rAxisLeft()
9451 {
9452 return getInput(btnAxisLeft, true);
9453 }
9454 bool rAxisRight()
9455 {
9456 return getInput(btnAxisRight, true);
9457 }
9458
9459 bool rF11()
9460 {
9461 return getInput(btnF11, true);
9462 }
9463 bool rQ()
9464 {
9465 return getInput(btnQ, true);
9466 }
9467 bool rI()
9468 {
9469 return getInput(btnI, true);
9470 }
9471
9472 13317771 bool DrunkUp()
9473 {
9474 13317771 return getInput(btnUp, false, true);
9475 }
9476 12417217 bool DrunkDown()
9477 {
9478 12417217 return getInput(btnDown, false, true);
9479 }
9480 7866450 bool DrunkLeft()
9481 {
9482 7866450 return getInput(btnLeft, false, true);
9483 }
9484 6829749 bool DrunkRight()
9485 {
9486 6829749 return getInput(btnRight, false, true);
9487 }
9488 5759186 bool DrunkcAbtn()
9489 {
9490 5759186 return getInput(btnA, false, true);
9491 }
9492 5722928 bool DrunkcBbtn()
9493 {
9494 5722928 return getInput(btnB, false, true);
9495 }
9496 5152193 bool DrunkcEx1btn()
9497 {
9498 5152193 return getInput(btnEx1, false, true);
9499 }
9500 5152213 bool DrunkcEx2btn()
9501 {
9502 5152213 return getInput(btnEx2, false, true);
9503 }
9504 bool DrunkcSbtn()
9505 {
9506 return getInput(btnS, false, true);
9507 }
9508 bool DrunkcMbtn()
9509 {
9510 return getInput(btnM, false, true);
9511 }
9512 bool DrunkcLbtn()
9513 {
9514 return getInput(btnL, false, true);
9515 }
9516 bool DrunkcRbtn()
9517 {
9518 return getInput(btnR, false, true);
9519 }
9520 bool DrunkcPbtn()
9521 {
9522 return getInput(btnP, false, true);
9523 }
9524
9525 bool DrunkrUp()
9526 {
9527 return getInput(btnUp, true, true);
9528 }
9529 bool DrunkrDown()
9530 {
9531 return getInput(btnDown, true, true);
9532 }
9533 bool DrunkrLeft()
9534 {
9535 return getInput(btnLeft, true, true);
9536 }
9537 bool DrunkrRight()
9538 {
9539 return getInput(btnRight, true, true);
9540 }
9541 4315794 bool DrunkrAbtn()
9542 {
9543 4315794 return getInput(btnA, true, true);
9544 }
9545 4328323 bool DrunkrBbtn()
9546 {
9547 4328323 return getInput(btnB, true, true);
9548 }
9549 71669 bool DrunkrEx1btn()
9550 {
9551 71669 return getInput(btnEx1, true, true);
9552 }
9553 71662 bool DrunkrEx2btn()
9554 {
9555 71662 return getInput(btnEx2, true, true);
9556 }
9557 bool DrunkrEx3btn()
9558 {
9559 return getInput(btnEx3, true, true);
9560 }
9561 bool DrunkrEx4btn()
9562 {
9563 return getInput(btnEx4, true, true);
9564 }
9565 bool DrunkrSbtn()
9566 {
9567 return getInput(btnS, true, true);
9568 }
9569 bool DrunkrMbtn()
9570 {
9571 return getInput(btnM, true, true);
9572 }
9573 4832892 bool DrunkrLbtn()
9574 {
9575 4832892 return getInput(btnL, true, true);
9576 }
9577 4830254 bool DrunkrRbtn()
9578 {
9579 4830254 return getInput(btnR, true, true);
9580 }
9581 bool DrunkrPbtn()
9582 {
9583 return getInput(btnP, true, true);
9584 }
9585
9586 6819 void eat_buttons()
9587 {
9588 6819 getInput(btnA, true, false, true);
9589 6819 getInput(btnB, true, false, true);
9590 6819 getInput(btnS, true, false, true);
9591 6819 getInput(btnM, true, false, true);
9592 6819 getInput(btnL, true, false, true);
9593 6819 getInput(btnR, true, false, true);
9594 6819 getInput(btnP, true, false, true);
9595 6819 getInput(btnEx1, true, false, true);
9596 6819 getInput(btnEx2, true, false, true);
9597 6819 getInput(btnEx3, true, false, true);
9598 6819 getInput(btnEx4, true, false, true);
9599 6819 }
9600
9601 // Is true for the _first frame_ of a key press.
9602 // But! it is possible that a script manually sets the value of KeyPress,
9603 // in which case it will be restored to the "true" value based on `key_current_frame`
9604 // and `key_previous_frame` on the next frame.
9605 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9606 {
9607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9609 {
9610 case KEY_F7:
9611 case KEY_F8:
9612 case KEY_F9:
9613 return KeyPress[k];
9614
9615 default:
9616
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 return KeyPress[k] && !disabledKeys[k];
9617 }
9618 14 }
9619
9620 // Is true for _every frame_ a key is held down.
9621 // But! it is possible that a script manually sets the value of KeyInput,
9622 // in which case it will be restored to the "true" value based on `key_current_frame`
9623 // on the next frame.
9624 bool zc_getkey(int32_t k, bool ignoreDisable)
9625 {
9626 if(ignoreDisable) return KeyInput[k];
9627 switch(k)
9628 {
9629 case KEY_F7:
9630 case KEY_F8:
9631 case KEY_F9:
9632 return KeyInput[k];
9633
9634 default:
9635 return KeyInput[k] && !disabledKeys[k];
9636 }
9637 }
9638
9639 // Reads (and then clears) the current frame key state directly.
9640 // Scripts can also modify `key_current_frame`.
9641 125 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9642 {
9643
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 123 times.
125 if(zc_getrawkey(k, ignoreDisable))
9644 {
9645 2 _key[k]=key[k]=key_current_frame[k]=0;
9646 2 return true;
9647 }
9648 123 _key[k]=key[k]=key_current_frame[k]=0;
9649 123 return false;
9650 125 }
9651
9652 // Reads the current frame key state directly.
9653 // Scripts can also modify `key_current_frame`.
9654 43497761 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9655 {
9656
2/2
✓ Branch 0 taken 36987119 times.
✓ Branch 1 taken 6510642 times.
43497761 if(ignoreDisable) return key_current_frame[k];
9657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510642 times.
6510642 switch(k)
9658 {
9659 case KEY_F7:
9660 case KEY_F8:
9661 case KEY_F9:
9662 return key_current_frame[k];
9663
9664 default:
9665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510642 times.
6510642 return key_current_frame[k] && !disabledKeys[k];
9666 }
9667 43497761 }
9668
9669 // Only used for a handful of keys, like tilde and Function keys.
9670 // This state is never read within the game.
9671 // It exists so that all keyboard input still functions during replay,
9672 // without inadvertently doing things like toggling throttling if the player
9673 // presses ~
9674 13021293 bool zc_get_system_key(int32_t k)
9675 {
9676 13021293 return key_system[k];
9677 }
9678
9679 // True for the _first_ frame of a key press.
9680 58595526 bool zc_read_system_key(int32_t k)
9681 {
9682 58595526 return key_system_press[k];
9683 }
9684
9685 826847978 bool is_system_key(int32_t k)
9686 {
9687
2/2
✓ Branch 0 taken 768252452 times.
✓ Branch 1 taken 58595526 times.
826847978 switch (k)
9688 {
9689 case KEY_BACKQUOTE:
9690 case KEY_CLOSEBRACE:
9691 case KEY_END:
9692 case KEY_HOME:
9693 case KEY_OPENBRACE:
9694 case KEY_PGDN:
9695 case KEY_PGUP:
9696 case KEY_TAB:
9697 case KEY_TILDE:
9698 58595526 return true;
9699 }
9700 768252452 return is_Fkey(k);
9701 826847978 }
9702
9703 6510614 void update_system_keys()
9704 {
9705
2/2
✓ Branch 0 taken 826847978 times.
✓ Branch 1 taken 6510614 times.
833358592 for (int32_t q = 0; q < 127; ++q)
9706 {
9707
2/2
✓ Branch 0 taken 136722894 times.
✓ Branch 1 taken 690125084 times.
826847978 if (!is_system_key(q))
9708 690125084 continue;
9709
9710 136722894 key_system[q] = key[q];
9711
1/2
✓ Branch 0 taken 136722894 times.
✗ Branch 1 not taken.
136722894 key_system_press[q] = key_system[q] && !key_system_previous[q];
9712 136722894 key_system_previous[q] = key_system[q];
9713 136722894 }
9714 6510614 }
9715
9716 7628080 void update_keys()
9717 {
9718
2/2
✓ Branch 0 taken 968766160 times.
✓ Branch 1 taken 7628080 times.
976394240 for (int32_t q = 0; q < 127; ++q)
9719 {
9720 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9721
1/2
✓ Branch 0 taken 968766160 times.
✗ Branch 1 not taken.
968766160 if (!replay_is_replaying())
9722 key_current_frame[q] = key[q];
9723
9724
2/2
✓ Branch 0 taken 961653306 times.
✓ Branch 1 taken 7112854 times.
968766160 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9725 968766160 KeyInput[q] = key_current_frame[q];
9726 968766160 key_previous_frame[q] = key_current_frame[q];
9727 968766160 }
9728 7628080 }
9729
9730 bool zc_disablekey(int32_t k, bool val)
9731 {
9732 switch(k)
9733 {
9734 case KEY_F7:
9735 case KEY_F8:
9736 case KEY_F9:
9737 return false;
9738
9739 default:
9740 disabledKeys[k] = val;
9741 return true;
9742 }
9743 }
9744
9745 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9746 {
9747 timer=timer;
9748 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9749 }
9750
9751 // these are here so that copy_dialog won't choke when compiling zelda
9752 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
9753 {
9754 return D_O_K;
9755 }
9756
9757 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
9758 {
9759 return D_O_K;
9760 }
9761
9762 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
9763 {
9764 return D_O_K;
9765 }
9766
9767 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
9768 {
9769 return D_O_K;
9770 }
9771
9772 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
9773 {
9774 return D_O_K;
9775 }
9776
9777 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
9778 {
9779 return D_O_K;
9780 }
9781
9782 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
9783 {
9784 return D_O_K;
9785 }
9786
9787 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
9788 {
9789 return D_O_K;
9790 }
9791
9792 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
9793 {
9794 return D_O_K;
9795 }
9796
9797 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
9798 {
9799 return D_O_K;
9800 }
9801
9802 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
9803 {
9804 return D_O_K;
9805 }
9806
9807 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
9808 {
9809 return D_O_K;
9810 }
9811
9812 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
9813 {
9814 return D_O_K;
9815 }
9816
9817 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
9818 {
9819 return D_O_K;
9820 }
9821
9822 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
9823 {
9824 return D_O_K;
9825 }
9826
9827 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
9828 {
9829 return D_O_K;
9830 }
9831
9832 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
9833 {
9834 return D_O_K;
9835 }
9836
9837 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
9838 {
9839 return D_O_K;
9840 }
9841
9842 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
9843 {
9844 return D_O_K;
9845 }
9846
9847 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
9848 {
9849 return D_O_K;
9850 }
9851
9852 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
9853 {
9854 return D_O_K;
9855 }
9856
9857 /*** end of zc_sys.cc ***/
9858
9859